#!/bin/sh 
#
# Configure -- configure lsof
#
# See the LSOF_HLP here document for usage.
#
# See the lsof distribution file 00XCONFIG for information on setting
# environment variables for cross-configuring lsof -- e.g., for configuring
# for Linux 2.3 on a machine running 2.4.  Marty Leisner suggested this
# support and provided the Linux Configure stanza modifications.
#
# When configuring for a particular dialect, <target-dialect>, this script
# requires that the subdirectory ./dialects/<target-dialect> contain a
# shell script, named $LSOF_MK, that places its source modules in this
# directory.
#
# $Id: Configure,v 1.161 2012/04/10 16:35:46 abe Exp $

# LSOF_CFLAGS_OVERRIDE=1 may be introduced through the environment to cause
#	the library Makefile's CFLAGS definition to override any in the
#	environment.

# LSOF_DISTRIBKVM may be introduced through the environment to specify the
#	Sun4 kernel virtual memory type of distrib.cf

LSOF_F="ddev.c dfile.c dlsof.h dmnt.c dnode*.c dproc.c dproto.h dsock.c dstore.c dzfs.h kernelbase.h machine.h machine.h.old new_machine.h __lseek.s"
LSOF_HLP_BASE=./cfghlp.
LSOF_HLP=${LSOF_HLP_BASE}$$

# LSOF_LOCALSUFFIX may be introduced through the environment to select a local
#	version of a Makefile.  It is used as a suffix to $LSOF_MKF.

# LSOF_MAKE may be introduced through the environment to specify a path to the
#	make command.   It defaults to `which make`, if that is non-NULL;
#	otherwise to the string "make".

if test "X$LSOF_MAKE" = "X"	# {
then
  LSOF_MAKE=`which make`
  if test "X$LSOF_MAKE" = "X"	# {
  then
    LSOF_MAKE=make
  fi	# }
fi	# }

LSOF_MK=Mksrc

# LSOF_MKC is the dialect's Mksrc create command -- default "ln -s".

# LSOF_MKFC may be introduced though the environment to change the name
# used for the created make file.

if test "X$LSOF_MKFC" = "X"	# {
then
  LSOF_MKFC=Makefile
fi	# }

LSOF_LIB=lib
LSOF_MKF=Makefile
LSOF_LIBMKF=Makefile
LSOF_LIBMKFSKEL=Makefile.skel

LSOF_VF=version

# Make sure no other variable important to Makefile construction is
# already set in the environment.
#
#	$AFS_VICE	    locatiion of AFS VICE directory
#				(default = /usr/vice)
#	$LSOF_AFS	    AFS temporary
#	$LSOF_AFS_NQ	    AFS-not-qualified flag
#	$LSOF_AFSV	    AFS version
#	$LSOF_AR	    archive command and its arguments for making the
#			    lsof library
#	$LSOF_ARCH	    Unix dialect architecture as a string (may be
#			    supplied externally)
#	$LSOF_CC	    C compiler name (may be supplied externally)
#	$LSOF_CCV	    C compiler version (may be supplied externally)
#	$LSOF_CDIR	    configuration directory
#	$LSOF_CFGD	    depend options
#	$LSOF_CFGDN	    depend file name
#	$LSOF_CFGF	    C flags -- e.g., -D's
#	$LSOF_CFGL	    last lsof library loader flags -- e.g., -l's
#	$LSOF_CINFO	    Configure information for LSOF_CINFO in version.h
#	$LSOF_CTFH	    Solaris 10 and above libctf.h status
#	$LSOF_CTFL	    Solaris 10 and above -lctf status
#	$LSOF_DEBUG	    Makefile's DEBUG string
#	$LSOF_DINC	    include flags -- -I's
#	$LSOF_DINC_ADD	    include flags status
#	$LSOF_DOC	    special document (man page) directory path
#	$LSOF_ERR	    internal error flag
#	$LSOF_FCFGL	    first lsof library loader flags -- e.g., -l's
#			    that must precede $LSOF_LIB
#	$LSOF_FBSD_ZFS      FreeBSD $LSOF_FBSD_ZFS_MKF status
#	$LSOF_FBSD_ZFS_CFGF FreeBSD ZFS configure flags
#	$LSOF_FBSD_ZFS_MKF  FreeBSD ZFS Makefile name
#	$LSOF_FBSD_ZFS_SYS  FreeBSD ZFS system sources location
#	$LSOF_HOST	    host name (e.g., from uname -n)
#	$LSOF_INCLUDE	    directory where header files are found
#			    (default = /usr/include)
#	$LSOF_LD	    loader name if not $LSOF_CC
#	$LSOF_LIB_NO	    if "N" don't configure the lsof library
#	$LSOF_LOCALSUFFIX   local suffix for Makefile
#	$LSOF_NBSD_BUFQH    NetBSD <sys/bufq.h> copy status
#	$LSOF_NBSD_PTYFS    NetBSD ${NETBSD_SYS}/sys/fs/ptyfs/ copy status
#	$LSOF_N_UNIXV	    *BSD system's kernel file
#	$LSOF_PL	    patch level
#	$LSOF_RANLIB	    randomizing command for the lsof library
#	$LSOF_RANLIB_SUP    if non-NULL $LSOF_RANLIB was supplied
#	$LSOF_SCRIPT_CALL   Customize and Inventory scripts call status
#	$LSOF_SPMKF	    Special Makefile name
#	$LSOF_TGT	    canonical target abbreviation (shortest)
#	$LSOF_TMP	    internal temporary
#	$LSOF_TMP1	    internal temporary
#	$LSOF_TMP2	    internal temporary
#	$LSOF_TMP3	    internal temporary
#	$LSOF_TMP4	    internal temporary
#	$LSOF_TMP5	    internal temporary
#	$LSOF_TMP6	    internal temporary
#	$LSOF_TMPC_BASE	    base name for $LSOF_TMPC
#	$LSOF_TMPC	    temporary C source file base name
#	$LSOF_TSTBIGF	    big file capability (for $LSOF_TSTCFLG)
#	$LSOF_TSTCC	    tests CC file
#	$LSOF_TSTCFLG	    tests CFLAGS file
#	$LSOF_TSTDFLG	    dialect-specific values for $LSOF_TSTCFLG
#	$LSOF_TSTK64	    status of 64 bit kernel (for $LSOF_TSTCFLG)
#	$LSOF_TSTKMEM	    /dev/kmem usage status (for $LSOF_TSTCFLG)
#	$LSOF_TSTLFF	    tests LDFLAGS file
#	$LSOF_TSTLFLG	    tests LDFLAGS values
#	$LSOF_TSTSUBD	    test subdirectory
#	$LSOF_TSTVPATH	    test v_path state (for $LSOF_TSTCFLG)
#	$LSOF_TSTXO	    test extra objects (for $LSOF_TSTXOC)
#	$LSOF_TSTXOC	    test extra objects file
#	$LSOF_UNSUP	    Lsof is unsupported on this dialect
#	$LSOF_VERS	    Unix dialect version as a decimal number (may
#			    be supplied externally)
#	$LSOF_VSTR	    Unix dialect version as a string -- may be supplied
#			    externally

if test "X$AFS_VICE" = "X"	# {
then
  AFS_VICE="/usr/vice"
fi	# }
LSOF_AFS=""
LSOF_AFS_NQ=""
LSOF_AFSV=""
if test "X$LSOF_ARCH" = "X"	# {
then
  LSOF_ARCH=""
fi	# }
LSOF_CDIR=""
LSOF_CFGD=""
LSOF_CFGDN=""
LSOF_CINFO=""
LSOF_CTFH=0
LSOF_CTFL=0
LSOF_DEBUG=""
LSOF_DOC=""
LSOF_ERR=""
LSOF_FCFGL=""
LSOF_FBSD_ZFS=0
LSOF_FBSD_ZFS_CFGF=""
LSOF_FBSD_ZFS_MKF="Makefile.zfs"
LSOF_FBSD_ZFS_SYS=""
LSOF_HOST=""
if test "X$LSOF_INCLUDE" = "X"	# {
then
  LSOF_DINC=""
  LSOF_INCLUDE="/usr/include"
else
  LSOF_DINC="-I$LSOF_INCLUDE"
fi	# }
LSOF_LD=""
LSOF_LIB_NO=""
LSOF_PL=""
if test "X$LSOF_RANLIB" = "X"	# {
then
  LSOF_RANLIB="ranlib"
  LSOF_RANLIB_SUP=""
else
  LSOF_RANLIB_SUP="Y"
fi	# }
LSOF_SCRIPT_CALL="yes"
LSOF_SPMKF=""
LSOF_TMP1=""
LSOF_TMP2=""
LSOF_TMPC_BASE=./lsof_Configure_tmp_
LSOF_TMPC=${LSOF_TMPC_BASE}$$
LSOF_TSTBIGF=""
LSOF_TSTSUBD="./tests"
LSOF_TSTCC="${LSOF_TSTSUBD}/config.cc"
LSOF_TSTCFLG="${LSOF_TSTSUBD}/config.cflags"
LSOF_TSTDFLG=""
LSOF_TSTK64=0
LSOF_TSTKMEM=1
LSOF_TSTLFF="${LSOF_TSTSUBD}/config.ldflags"
LSOF_TSTLFLG=""
LSOF_TSTVPATH=0
LSOF_TSTXO=""
LSOF_TSTXOC="${LSOF_TSTSUBD}/config.xobj"
LSOF_UNSUP="WARNING: unsupported dialect or version"
if test "X$LSOF_VERS" = "X"	# {
then
  LSOF_VERS=""
fi	# }
if test "X$LSOF_VSTR" = "X"	# {
then
  LSOF_VSTR=""
fi	# }

# Establish echo type -- Berkeley or SYSV.

j=`echo -n ""`
if test "X$j" = "X-n "
then
  EC="\c"
  EO=""
else
  EC=""
  EO="-n"
fi

# Make sure temporary files are removed before an abnormal exit.

trap 'rm -f ${LSOF_HLP_BASE}* ${LSOF_TMPC_BASE}*; exit 1' 1 2 3 15

rm -f $LSOF_HLP
cat > $LSOF_HLP << LSOF_HLP
Usage: Configure <options> <target-dialect>
  <options>:  -clean        : clean up previous configuration
              -d|-dialects  : display a list of supported dialect versions
              -h|-help      : display help information
              -n            : avoid AFS, customization, and inventory checks
  <target-dialect> (****USE -d TO GET TESTED DIALECT VERSION NUMBERS****):
    aix|aixgcc              : IBM AIX xlc (aix) or gcc (aixgcc)
    darwin                  : Apple Darwin
    decosf                  : DEC OSF/1
    digital_unix|du         : Digital UNIX
    freebsd                 : FreeBSD
    hpux|hpuxgcc            : HP-UX cc (hpux) or gcc (hpuxgcc)
    linux                   : Linux
    netbsd                  : NetBSD
    nextstep|next|ns|nxt    : NEXTSTEP
    openbsd                 : OpenBSD
    openstep|os             : OPENSTEP
    osr|sco                 : SCO OpenServer < 6.0.0, SCO devloper's compiler
    osrgcc|scogcc           : SCO OpenServer < 6.0.0, gcc compiler
    osr6                    : SCO OpenServer 6.0.0, SCO compiler
    solaris|solariscc       : Solaris gcc (solaris) or cc (solariscc)
    tru64		    : Tru64 UNIX
    unixware|uw             : SCO|Caldera UnixWare
LSOF_HLP

LSOF_TGT="no-target"

args=$#
while test $args -gt 0	# {
do
  case $1 in	# {
    -clean)
      if test -r $LSOF_MKFC	# {
      then
	echo "$LSOF_MAKE -f $LSOF_MKFC clean"
	$LSOF_MAKE -f $LSOF_MKFC clean
      else
	if test -r ${LSOF_LIB}/${LSOF_LIBMKF}	# {
	then
	  echo "(cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF} clean)"
	  (cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF} clean)
	else
	  if test -r ${LSOF_LIB}/${LSOF_LIBMKF}.skel	# {
	  then
	    echo "(cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF}.skel clean)"
	    (cd ${LSOF_LIB}; $LSOF_MAKE -f ${LSOF_LIBMKF}.skel clean)
	  fi	# }
	fi	# }
      fi	# }
      if test -r ${LSOF_TSTSUBD}/Makefile	# {
      then
	echo "(cd ${LSOF_TSTSUBD}; $LSOF_MAKE spotless)"
	(cd ${LSOF_TSTSUBD}; $LSOF_MAKE spotless)
      else
	echo '(cd ${LSOF_TSTSUBD}; rm *.o config.*)'
	(cd ${LSOF_TSTSUBD}; rm *.o config.*)
      fi	# }
      rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF ${LSOF_TMPC_BASE}*
      echo rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF ${LSOF_TMPC_BASE}*
      rm -rf AFSHeaders AFSVersion solaris11 version.h vnode_if.h
      echo "rm -rf AFSHeaders AFSVersion solaris11 version.h vnode_if.h"
      rm -f ${LSOF_HLP_BASE}* cd9660_node.h lockf_owner.h fbsd_minor.h
      echo "rm -f ${LSOF_HLP_BASE}* cd9660_node.h lockf_owner.h fbsd_minor.h"
      rm -f dialects/aix/aix5/j2/j2_snapshot.h
      echo "rm -f dialects/aix/aix5/j2/j2_snapshot.h"
      rm -f dialects/sun/solaris10	# DEBUG -- for s10_44
      echo "rm -f dialects/sun/solaris10"	# DEBUG -- for s10_44
      rm -f dialects/du/du5_sys_malloc.h
      echo "rm -f dialects/du/du5_sys_malloc.h"
      rm -f dialects/hpux/kmem/hpux_mount.h
      echo "rm -f dialects/hpux/kmem/hpux_mount.h"
      rm -rf dialects/n+obsd/include
      echo "rm -rf dialects/n+obsd/include"
      rm -f dialects/uw/uw7/vm/swap.h
      echo "rm -f dialects/uw/uw7/vm/swap.h"
      rm -f ${LSOF_LIB}/${LSOF_LIBMKF}
      echo "rm -f ${LSOF_LIB}/${LSOF_LIBMKF}"
      exit 0
      ;;
 
    -d|-dialects)
      if test -r ./00DIALECTS -a -r ./version	# {
      then
	V=`sed '/VN/s/.ds VN \(.*\)/\1/' version`
	echo "lsof $V has been *tested* on these UNIX dialect versions:"
	cat 00DIALECTS
	echo Although "$V hasn't been tested on other versions of these dialects,"
	echo "it may work.  Try \`Configure <dialect>\` and \`make\` to see."
	rm -f $LSOF_HLP
	exit 0
      else
	echo "Can't display UNIX dialect version information:"
	if test ! -r ./00DIALECTS	# {
	then
	  echo "	./00DIALECTS is inaccessible."
	fi	# }
	if test ! -r ./version	# {
	then
	  echo "	./version is inaccessible."
	fi	# }
	rm -f $LSOF_HLP
	exit 1
      fi	# }
      ;;

    -h|-help) cat $LSOF_HLP
      rm -f $LSOF_HLP
      exit 0
      ;;

    -n*)
      LSOF_SCRIPT_CALL="no"
      ;;

    *)
      if test "X$LSOF_TGT" != "Xno-target"	# {
      then
	echo "Only one dialect may be configured at a time."
	echo 'Both "$LSOF_TGT" and "$1" were specified.'
	cat $LSOF_HLP
	rm -f $LSOF_HLP
	exit 1
      else
	LSOF_TGT=$1
      fi	# }
      ;;
  esac	# }
  shift
  args=`expr $args - 1`
done	# }

case $LSOF_TGT in	# {
 no-target)
   echo "No target dialect was specified."
   cat $LSOF_HLP
   rm -f $LSOF_HLP
   exit 1
   ;;

# Configure for AIX xlc and AIX gcc.

  aix|aixgcc)

  # AIXA stands for AIX architecture.  It is assigned these values in this
  # stanza:
  #
  #    0	The AIX version is < 5.0, or the AIX 5.0 architecture is
  #		Power and the kernel bit size is 32.
  #
  #    1	The AIX version is >= 5.0, the AIX architecture is Power,
  #		and the kernel bit size is 64.
  #
  #    2	The AIX version is >= 5.0 and the architecture is IA64.

    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB="@echo \\\\\\\\c"    # AIX make doesn't like a null ${RANLIB}.
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then

      # If the AIX version isn't pre-defined, determine it.

      LSOF_TMP1=`uname -v`
      if test "X$LSOF_TMP1" = "X5"	# {
      then

	# If the AIX version is 5, build the version string with `uname -rv`
	# output.

	  LSOF_VSTR=`uname -r | awk '{printf "5.%d.0.0\n",\$1}'`
	  echo "Uname reports the version is $LSOF_VSTR."
      else

	# See if oslevel can determine the version.

	LSOF_TMP1=/usr/bin/oslevel
	if test -x $LSOF_TMP1	# {
	then
	  echo "Determining AIX version with $LSOF_TMP1."
	  echo "This may take a while, depending on your maintenance level."
	  LSOF_VSTR=`$LSOF_TMP1 | sed 's/[^0-9]*\([0-9\.]*\).*/\1/'`
	  echo "$LSOF_TMP1 reports the version is $LSOF_VSTR."
	else

	  # If oslevel can't be used, build the version string with
	  # `uname -rv` and issue a warning.

	  LSOF_VSTR=`uname -rv | awk '{printf "%d.%d.0.0\n",\$2,\$1}'`
	  echo "WARNING: can't execute $LSOF_TMP1; uname -rv reports"
	  echo "         the version is $LSOF_VSTR; edit CFGF in Makefile and"
	  echo "         lib/Makefile to refine AIXV and LSOF_VSTR."
	fi	# }
      fi	# }
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then
      LSOF_VERS=`echo $LSOF_VSTR | sed 's/\.//g'`
    fi	# }
    if test $LSOF_VERS -ge 4320	# {
    then
      LSOF_TSTBIGF=" "
    fi	# }
    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xaixgcc"	# {
      then
	LSOF_CC=gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
      else
	LSOF_CC=cc
      fi	# }
    fi	# }
    LSOF_TGT="aix"
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0	# {
    then

    # Prevent use of gcc for AIX below 4.1.

      if test $LSOF_VERS -lt 4100	# {
      then
	echo "********************************************************"
	echo "* Sorry, but gcc can't be used to compile lsof for AIX *"
	echo "* versions less than 4.1, because of possible kernel   *"
	echo "* structure alignment differences between it and xlc.  *"
	echo "********************************************************"
	rm -f $LSOF_HLP
	exit 1
      fi	# }
    fi	# }

    # Test for AFS.

    if test "X$AIX_HAS_AFS" != "X"	# {
    then
      LSOF_AFS=$AIX_HAS_AFS
    fi	# }
    if test "X$LSOF_AFS" != "Xno"	# {
    then
      if test "X$LSOF_AFS" = "Xyes" -o -r ${AFS_VICE}/etc/ThisCell	# {
      then
	if test "X$LSOF_AFS" != "Xyes"	# {
	then
	  if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
	  then
	    if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  else
	    if test ! -x ./AFSConfig	# {
	    then
	      echo "Can't find or execute the AFSConfig script"
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	    ./AFSConfig
	    if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  fi	# }
	fi	# }
	if test "X$LSOF_AFS" = "Xyes"	# {
	then
	  if test "X$LSOF_AFSV" = "X"	# {
	  then
	    if test -r ./AFSVersion	# {
	    then
	      LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	    else
	      echo "!!!FATAL: no ./AFSVersion file.  It should have been"
	      echo "          created by a previous AFS configuration run."
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	  fi	# }
	  if test $LSOF_VERS -gt 4330 -o LSOF_AFSV -gt 305	# {
	  then
	    echo "!!!FATAL: Lsof does not support AFS on this combination of"
	    echo "          AIX ($LSOF_VERS) and AFS ($LSOF_AFSV) versions."
	    echo "          To disable AFS, set the value of the AIX_HAS_AFS"
	    echo "          environment variable to \"no\"."
	    rm -f $LSOF_HLP
	    exit 1
	  else
	    LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	    LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
	    if test -r ${LSOF_INCLUDE}/sys/inttypes.h  # {
	    then
	      grep "^typedef.*int16;" ${LSOF_INCLUDE}/sys/inttypes.h > /dev/null
	      if test $? -eq 0      # {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHASINT16TYPE"
	      fi    # }
	      grep "^typedef.*u_int32;" ${LSOF_INCLUDE}/sys/inttypes.h > /dev/null
	      if test $? -eq 0      # {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHASUINT16TYPE"
	      fi    # }
	      grep "^typedef.*int32;" ${LSOF_INCLUDE}/sys/inttypes.h > /dev/null
	      if test $? -eq 0      # {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHASINT32TYPE"
	      fi    # }
	    fi	# }
	  fi      # }
	fi	# }
      fi	# }
    fi	# }

    # Miscellaneous AIX tests

    if test -d ${LSOF_INCLUDE}/nfs	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_NFS"
    fi	# }
    echo $LSOF_CC | grep cc | grep -v gcc > /dev/null
    if test $? -eq 0 -a $LSOF_VERS -ge 4140 -a $LSOF_VERS -lt 5000	# {
    then
      LSOF_CFGL="$LSOF_CFGL -bnolibpath"
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/socket.h	# {
    then
      grep AF_INET6 ${LSOF_INCLUDE}/sys/socket.h > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/stat.h	# {
    then
      grep stat64 ${LSOF_INCLUDE}/sys/stat.h > /dev/null
      if test $? -eq 0 # {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASSTAT64"
      fi	# }
    fi	# }
#DEBUG SANFS    if test -r ${LSOF_INCLUDE}/sys/sanfs/sanfsnode.h???	# {
#DEBUG SANFS    then
#DEBUG SANFS      LSOF_CFGF="$LSOF_CFGF -DHAS_SANFS"
#DEBUG SANFS    fi	# }
    if test $LSOF_VERS -ge 5000	# {
    then

    # This is AIX 5 or greater.

      if test -d ${LSOF_INCLUDE}/j2	# {
      then

      # The AIX > 5.0 system has jfs2 support.  Make the necesssary definitions
      # and adjustments.

	rm -f dialects/aix/aix5/j2/j2_snapshot.h
	(cd dialects/aix/aix5/j2; ln -s private_j2_snapshot.h j2_snapshot.h)
	LSOF_CFGF="$LSOF_CFGF -DHAS_JFS2"
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/aix/aix5"
	if test $LSOF_VERS -ge 5200	# {
	then
	  if test -r ${LSOF_INCLUDE}/j2/j2_snapshot.h	# {
	  then

	  # The system has its own j2_snapshot.h, so make sure the
	  # private lsof copy is discarded.

	    rm -f dialects/aix/aix5/j2/j2_snapshot.h
	  fi	# }
	  echo $LSOF_CC | grep gcc > /dev/null
	  if test $? -eq 0	# {
	  then

	  # Test gcc version for AIX 5.2.

	    LSOF_TMP1=`echo $LSOF_CCV | awk -F . '{printf "%d%02d",$1,$2}'`
	    if test $LSOF_TMP1 -ge 303	# {
	    then

	    # Add gcc >= 3.3 option to handle use of i_dev from the wInode
	    # anonymous structure reference in the JFS2 inode structure of
	    # <j2/j2_inode.h>.

	      LSOF_CFGF="$LSOF_CFGF -fms-extensions"
	    fi	# }
	  fi	#}
	fi	# }
      fi	# }

      # Determine the AIX architecture type and set AIXA accordingly.

      if test "X$AIX_ARCH" = "X"	# {
      then
	uname -a | grep -i ia64 > /dev/null
	if test $? -eq 0	# {
	then
	  AIX_ARCH="ia64"
	else
	  AIX_ARCH=""
	fi	# }
      fi	# }
      if test "X$AIX_ARCH" = "Xia64"	# {
      then

      # This is AIX >= 5 on ia64.

	LSOF_TSTK64=1
	echo $LSOF_CC | grep gcc > /dev/null
	if test $? -eq 0	# {
	then

	# Quit if gcc was specified as the compiler, since the gcc options to
	# do an ia64 lsof compilation are unknown.

	  echo "*************************************************************"
	  echo "*                                                           *"
	  echo "* !!!!!!!!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!!!!!!!!! *"
	  echo "*                                                           *"
	  echo "* Gcc can't be used to compile lsof for AIX 5 and above on  *"
	  echo "* the ia64 architecture.  Consult lsof's FAQ (in the file   *"
	  echo "* 00FAQ) for more information.                              *"
	  echo "*                                                           *"
	  echo "*************************************************************"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	LSOF_TMP1=2
	if test "X$LSOF_AR" = "X"	# {
	then
	  LSOF_AR="/usr/bin/ar cr"
	fi	# }
	LSOF_CFGF="$LSOF_CFGF -q64"
	LSOF_CFGL="$LSOF_CFGL -lelf"
      else

      # This is AIX >= 5 on Power architecture.

	echo $LSOF_CC | grep cc | grep -v gcc > /dev/null
	if test $? -eq 0	# {
	then
	  LSOF_CFGL="$LSOF_CFGL -bnolibpath"
	fi	# }
	if test "X$AIX_KERNBITS" = "X"	# {
	then

	# The kernel bit size wasn't predefined.  Determine it by compiling
	# and executing a test program.

	  rm -f ${LSOF_TMPC}.*
	  echo "#include <sys/systemcfg.h>" > ${LSOF_TMPC}.c
	  echo 'main(){ if (__KERNEL_32()) printf("32\\n");' >> ${LSOF_TMPC}.c
	  echo 'else if (__KERNEL_64()) printf("64\\n");' >> ${LSOF_TMPC}.c
	  echo 'else printf("0\\n");' >> ${LSOF_TMPC}.c
	  echo "return(0); }" >> ${LSOF_TMPC}.c
	  echo "Testing kernel bit size with $LSOF_CC"
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x
	  if test ! -x ${LSOF_TMPC}.x	# {
	  then
	    echo "!!!FATAL: can't compile test program, ${LSOF_TMPC}.c."
	    rm -f $LSOF_HLP rm -f ${LSOF_TMPC}.*
	    exit 1
	  fi	# }
	  AIX_KERNBITS=`./${LSOF_TMPC}.x`
	  rm -f ${LSOF_TMPC}.*
	fi	# }

      # Use the kernel bit size specification to select archiver and compiler
      # options, and to update AIXA.

	case $AIX_KERNBITS in	# {
	32)
	  if test "X$LSOF_AR" = "X"	# {
	  then
	    LSOF_AR="/usr/bin/ar cr"
	  fi	# }
	  LSOF_TMP1=0
	  ;;
	64)
	  if test "X$LSOF_AR" = "X"	# {
	  then
	    LSOF_AR="/usr/bin/ar -X 64 -v -q"
	  fi	# }
	  LSOF_TSTK64=1
	  LSOF_TMP1=1
	  echo $LSOF_CC | grep gcc > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -maix64"
	  else
	    LSOF_CFGF="$LSOF_CFGF -q64"
	  fi	# }
	  ;;
	*)
	  echo "!!!FATAL: unrecognized kernel bit size: $AIX_KERNBITS"
	  rm -f $LSOF_HLP
	  exit 1
	esac	# }

      # Put kernel bit size information in $LSOF_CINFO and $LSOF_CFGF.

	echo "Kernel bit size: $AIX_KERNBITS"
	LSOF_TMP2="${AIX_KERNBITS} bit kernel"
	if test "X$LSOF_CINFO" != "X"	# {
	then
	  LSOF_CINFO="${LSOF_CINFO}  ${LSOF_TMP2}"
	else
	  LSOF_CINFO="${LSOF_TMP2}"
	fi	# }
	LSOF_CFGF="$LSOF_CFGF -DAIX_KERNBITS=${AIX_KERNBITS}"
      fi	# }
      LSOF_CFGF="$LSOF_CFGF -DAIXA=$LSOF_TMP1"
      if test "X$LSOF_TSTDFLG" = "X"	# {
      then
	LSOF_TSTDFLG="-DLT_AIXA=$LSOF_TMP1"
      else
	LSOF_TSTDFLG="$LSOF_TSTDFLG -DLT_AIXA=$LSOF_TMP1"
      fi	# }
    else

    # AIX is < 5, so set AIXA accordingly.

      LSOF_CFGF="$LSOF_CFGF -DAIXA=0"
      if test "X$LSOF_TSTDFLG" = "X"	# {
      then
	LSOF_TSTDFLG="-DLT_AIXA=0"
      else
	LSOF_TSTDFLG="$LSOF_TSTDFLG -DLT_AIXA=0"
      fi	# }
    fi	#}
    LSOF_CFGF="$LSOF_CFGF -DAIXV=$LSOF_VERS"
    LSOF_DIALECT_DIR=aix
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0 	# {
    then

    # Do gcc tests.

      if test $LSOF_VERS -ge 4100 -a $LSOF_VERS -lt 4200	# {
      then
	if test "X$AIX_USHACK" = "X"	# {
	then

	  # Compile and run a gcc test program to evaluate the user structure.

	  rm -f ${LSOF_TMPC}.*
	  echo "#include <stddef.h>" > ${LSOF_TMPC}.c
	  echo "#include <sys/user.h>" >> ${LSOF_TMPC}.c
	  echo "main(){exit((offsetof(struct user, U_irss) & 0x7) ? 1 : 0);}" >>${LSOF_TMPC}.c
	  echo "Testing user.h with $LSOF_CC"
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x
	  if ! ${LSOF_TMPC}.x	# {
	  then
	    LSOF_TMP1=1
	  else
	    LSOF_TMP1=0
	  fi	# }
	  rm -f ${LSOF_TMPC}.*
	else
	  if test "$AIX_USHACK" = "Y" -o "$AIX_USHACK" = "y"	# {
	  then
	    LSOF_TMP1=1
	  else
	    LSOF_TMP1=0
	  fi	# }
	fi	# }
	if test ${LSOF_TMP1} -eq 1	# {
	then
	  echo "Applying gcc AIX 4.1+ user struct alignment hack"
	  rm -rf ./dialects/aix/aix$LSOF_VERS
	  mkdir ./dialects/aix/aix$LSOF_VERS
	  mkdir ./dialects/aix/aix${LSOF_VERS}/sys
	    sed 's/U_irss\[/dummy_for_alignment, U_irss\[/' < ${LSOF_INCLUDE}/sys/user.h > ./dialects/aix/aix${LSOF_VERS}/sys/user.h
	    LSOF_CFGF="$LSOF_CFGF -U_LONG_LONG -I`pwd`/dialects/aix/aix$LSOF_VERS"
	fi	# }
      fi	# }
    else

      # Get xlc version number

      rm -f ${LSOF_TMPC}.*
      echo "main(){}" > ${LSOF_TMPC}.c
      echo "Getting version number of ${LSOF_CC}."
      $LSOF_CC -c ${LSOF_TMPC}.c -I${LSOF_INCLUDE} -o ${LSOF_TMPC}.o -qlist > /dev/null 2>&1
      LSOF_CCV=`head -1 ${LSOF_TMPC}.lst | sed 's/\(.*\) ---.*/\1/'`
      rm ${LSOF_TMPC}.*
      echo "The version is \"${LSOF_CCV}\"."
      echo $LSOF_CCV | grep "Version [0-9]" > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_TMP=`echo $LSOF_CCV | sed 's/.*Version \([0-9]*\).*/\1/'`
	if test "X$LSOF_TMP" != "X" -a $LSOF_TMP -ge 4    # {
	then
	  if test $LSOF_TMP -ge 6	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -qmaxmem=-1"
	  else
	    LSOF_CFGF="$LSOF_CFGF -qmaxmem=16384"
	  fi	# }
	fi	# }
      fi	# }
    fi	# }
    if test $LSOF_VERS -ge 5300	# {
    then
      LSOF_UNSUP=""
    fi	# }
    ;;

# Configure for Apple Darwin.

  darwin)
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

    # If the Darwin / Mac OS X version isn't pre-defined, determine it.

      case $LSOF_VSTR in	# {
      1.2*)
	LSOF_VERS=120
	;;
      1.3*)
	LSOF_VERS=130
	;;
      1.4*)
	LSOF_VERS=140
	;;
      5.[012]*)
	LSOF_VERS=500
	;;
      5.[3-9]*)
	LSOF_VERS=530
	;;
      6.*)
	LSOF_VERS=600
	;;
      7.*)			# Mac OS X 10.3 (Panther)
	LSOF_VERS=700
	;;
      8.*)			# Mac OS X 10.4 (Tiger)
	LSOF_VERS=800
	;;
      9.*)			# Mac OS X 10.5 (Leopard)
	LSOF_VERS=900
 	;;
      10.*)			# Mac OS X 10.6 (SnowLeopard)
 	LSOF_VERS=1000
 	;;
      11.*)			# Mac OS X 10.7 (Lion)
 	LSOF_VERS=1100
 	;;
      12.*)			# Next Mac OS X
 	LSOF_VERS=1200
 	;;
      *)
	echo Unknown Darwin release: `uname -r`
	echo Assuming Darwin 11.0
	LSOF_VERS=1100
	;;
      esac	# }
    fi	# }

    # Do Darwin version-specific stuff.

    case $LSOF_VERS in	# {
    120|130)
      LSOF_TMP1="hfs/hfs.h hfs/hfs_macos_defs.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h"
      ;;
    140|500)
      LSOF_TMP1="hfs/hfs.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h"
      ;;
    530)
      LSOF_TMP1="hfs/hfs.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h net/ndrv.h net/ndrv_var.h"
      ;;
    600)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1="hfs/hfs.h hfs/hfs_catalog.h hfs/hfs_cnode.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h net/ndrv_var.h net/raw_cb.h netinet/ip_var.h netinet/tcp_var.h"
      ;;
    700)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1="hfs/hfs.h hfs/hfs_catalog.h hfs/hfs_cnode.h hfs/hfs_macos_defs.h hfs/rangelist.h miscfs/devfs/devfsdefs.h miscfs/devfs/devfs_proto.h miscfs/fdesc/fdesc.h net/ndrv_var.h net/raw_cb.h netinet/ip_var.h netinet/tcp_var.h sys/eventvar.h"
      ;;
    800)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1="net/ndrv_var.h net/raw_cb.h netinet/ip_var.h netinet/tcp_var.h sys/eventvar.h sys/file_internal.h sys/mount_internal.h sys/proc_internal.h sys/vnode_internal.h"
      ;;
    900|1000|1100)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1=""
      LSOF_UNSUP=""
      LSOF_TSTBIGF=" "			# enable LTbigf test
      ;;
    1200)
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      LSOF_TMP1=""
      ;;
    *)
      echo "Unsupported Darwin version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_TMP2=""
    LSOF_TMP3=""
    LSOF_TMP4=""
    LSOF_CFGF="$LSOF_CFGF -mdynamic-no-pic"
    LSOF_CFGL="$LSOF_CFGL -lcurses"

    if test "X$DARWIN_XNUDIR" != "X"	# {
    then
      LSOF_TMP2="${DARWIN_XNUDIR}/bsd"
      LSOF_TMP3="${DARWIN_XNUDIR}/osfmk"
      LSOF_TMP4=""
    else
      LSOF_TMP2="${DARWIN_XNU_HEADERS}/System/Library/Frameworks/Kernel.framework/Versions/A/PrivateHeaders"
      LSOF_TMP3="${DARWIN_XNU_HEADERS}/System/Library/Frameworks/System.framework/Versions/B/PrivateHeaders"
      LSOF_TMP4=""
      if test "X$DARWIN_XNU_HEADERS" != "X"	# {
      then
	LSOF_TMP4="${DARWIN_XNU_HEADERS}/usr/include"
      fi	# }
    fi	# }

    # Test Darwin base.

    if test "X$DARWIN_BASE" = "X" -o "X$DARWIN_BASE" = "Xlibproc"	# {
    then
      LSOF_TMP5=""
      if test $LSOF_VERS -ge 800 -o "X$DARWIN_BASE" = "Xlibproc"	# {
      then
	if test -r ${LSOF_INCLUDE}/libproc.h	# {
	then
	    DARWIN_BASE="libproc"
	else
	  if test -r ${LSOF_INCLUDE}/../local/include/libproc.h	# {
	  then
	    DARWIN_BASE="libproc"
	    LSOF_TMP5="-I${LSOF_INCLUDE}/../local/include"
	  else
	    echo "FATAL: can't find libproc.h"
	    rm -f $LSOF_HLP
	    exit 1
	  fi	# }
	fi	# }
      else

      # The default Darwin base is /dev/kmem.

	DARWIN_BASE="/dev/kmem"
      fi	# }
    fi	# }
    if test "X$DARWIN_BASE" = "Xlibproc"	# {
    then

    # Configure for libproc-based Darwin lsof.

      echo "Configuring libproc-based Darwin lsof"
      LSOF_CINFO="libproc-based"
      LSOF_DIALECT_DIR=darwin/libproc
      if test $LSOF_VERS -lt 1000 	# {
      then
	LSOF_CFGL="$LSOF_CFGL -lproc"
      fi	# }
      LSOF_TSTKMEM=0
      LSOF_DINC="$LSOF_DINC $LSOF_TMP5"
      if test ! -r ${LSOF_INCLUDE}/sys/proc_info.h	# {
      then
	if test "X$LSOF_TMP5" = "X" -o ! -r ${LSOF_TMP5}/sys/proc_info.h # {
	then
	  echo "FATAL: can't find sys/proc_info.h"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
      fi	# }

    # Add header file paths for libproc-based Darwin lsof.

      for i in $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
      do
	if test -d $i -a "X$i" != "X/usr/include"	# {
	then
	  LSOF_DINC="$LSOF_DINC -I${i}"
	fi	# }
      done	# }

    # Do other libproc-based Darwin lsof setups.
      
      if test -r ${LSOF_INCLUDE}/utmpx.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASUTMPX"
      fi	# }
    else
      if test "X$DARWIN_BASE" != "X/dev/kmem"	# {
      then
	echo "Darwin base unrecognized: $DARWIN_BASE"
	rm -f $LSOF_HLP
	exit 1
      fi	# }
    
    # Configure for /dev/kmem-based Darwin lsof.

      echo "Configuring /dev/kmem-based Darwin lsof"
      LSOF_CINFO="/dev/kmem-based"
      LSOF_DIALECT_DIR=darwin/kmem

    # Make sure needed /dev/kmem-base XNU Darwin kernel header files are
    # present.

      LSOF_TMP5=""
      for i in $LSOF_TMP1	# {
      do
	LSOF_TMP6=0
	for j in $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
	do
	  if test "X${j}" != "X" -a -r ${j}/${i}  # {
	  then
	    LSOF_TMP6=1
	    break
	  fi	# }
	done	# }
	if test $LSOF_TMP6 -ne 1	# {
	then
	  if test "X$LSOF_TMP5" = "X"	# {
	  then
	    LSOF_TMP5=$i
	  else
	    LSOF_TMP5="$LSOF_TMP5 $i"
	  fi	# }
	fi			# }
      done	# }
      if test "X$LSOF_TMP5" != "X"	# {
      then

      # If any Darwin XNU kernel header files are missing, call the
      # get-hdr-loc.sh script to find the path.

	LSOF_TMP6=`pwd`/dialects/darwin/get-hdr-loc.sh
	if test ! -x $LSOF_TMP6	# {
	then
	  echo "FATAL: can't execute: $LSOF_TMP6"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	DARWIN_XNUDIR=`$LSOF_TMP6 $LSOF_TMP5`
	if test $? -ne 0	# {
	then
	  echo "FATAL: $LSOF_TMP6 returns: $DARWIN_XNUDIR"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	LSOF_TMP2="${DARWIN_XNUDIR}/bsd"
	LSOF_TMP3="${DARWIN_XNUDIR}/osfmk"
	LSOF_TMP4=""
      fi	# }

    # Add header file paths for /dev/kmem-based Darwin lsof.

      for i in $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
      do
	if test -d $i -a "X$i" != "X/usr/include"	# {
	then
	  LSOF_DINC="$LSOF_DINC -I${i}"
	fi	# }
      done	# }

    # Make conditional feature definitions for /dev/kmem-based Darwin lsof.

      for i in $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE      # {
      do
	if test "X${i}" != "X" -a -r ${i}/sys/namei.h	# {
	then
	  grep -q nc_vpid ${i}/sys/namei.h
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
	  fi	# }
	  break
	fi	# }
      done	# }
      for i in $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 $LSOF_INCLUDE	# {
      do
	if test "X${i}" != "X"	# {
	then
	  if test $LSOF_VERS -ge 800	# {
	  then
	    if test -r ${i}/sys/file_internal.h	# {
	    then
	      grep -q DTYPE_KQUEUE ${i}/sys/file_internal.h
	      if test $? -eq 0	# {
	      then
	        LSOF_CFGF="$LSOF_CFGF -DHASKQUEUE"
	      fi	# }
	      break
	    fi	# }
	  else
	    if test $LSOF_VERS -ge 700	# {
	    then
	      if test -r ${i}/sys/file.h	# {
	      then
	        grep -q DTYPE_KQUEUE ${i}/sys/file.h
	        if test $? -eq 0	# {
	        then
	          LSOF_CFGF="$LSOF_CFGF -DHASKQUEUE"
	        fi	# }
	      fi	# }
	      break
	    fi	# }
	  fi	# }
	fi	# }
      done	# }
      LSOF_CFGF="$LSOF_CFGF -DHAS9660FS"
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DDARWINV=$LSOF_VERS"
    LSOF_CFLAGS_OVERRIDE=1
    ;;

# Configure for DEC OSF/1, Digital UNIX, or Tru64 UNIX.

  digital_unix|du|decosf|tru64)
    LSOF_TGT="du"
    LSOF_TSTBIGF=" "
    LSOF_TSTK64=1
    if test "X$LSOF_DINC" = "X"	# {
    then
      LSOF_DINC="-I/usr/include"
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the DEC OSF/1, Digital UNIX, or Tru64 UNIX version isn't
      # predefined, determine it.

      case $LSOF_VSTR in	# {
      V2.0)
	LSOF_VERS=20000
	;;
      V3.0)
	LSOF_VERS=30000
	;;
      V3.2)
	LSOF_VERS=30200
	;;
      ?4.0)
	LSOF_TSTXO="../lib/snpf.o"
	LSOF_VERS=40000
	;;
      ?5.0)
	LSOF_VERS=50000
	;;
      ?5.1)
	LSOF_VERS=50100
	;;
      *)
	echo "WARNING: unknown version; assuming version is 2.0"
	LSOF_VERS=20000
	;;
      esac	# }
    fi	# }

    # Do DEC OSF/1, Digital UNIX, or Tru64 UNIX version specific stuff.

    case $LSOF_VERS in	# {
      20000)
	LSOF_CFGF="$LSOF_CFGF -Olimit 1024"
	LSOF_TMP1="/sys"
	;;
      30000)
	LSOF_CFGF="$LSOF_CFGF -Olimit 1024"
	LSOF_TMP1="/sys"
	LSOF_TMP2=-DUSELOCALREADDIR
	;;
      30200)
	LSOF_CFGF="$LSOF_CFGF -Olimit 1024"
	LSOF_TMP1="/sys"
	LSOF_TMP2=-DUSELOCALREADDIR
	;;
      40000)
	LSOF_TMP1="/usr/sys"
	;;
      50000|50100)
	LSOF_CFGF="$LSOF_CFGF -DUSE_STAT"
	LSOF_TMP1="/usr/sys"
	;;
      *)
	echo "WARNING: unknown version: $LSOF_VERS"
	rm -f $LSOF_HLP
	exit 1
	;;
    esac	# }
    if test "X$DU_SYSDIR" = "X"	# {
    then
      DU_SYSDIR=$LSOF_TMP1
    fi	# }
    LSOF_HOST=`uname -n`
    if test "X$DU_CDIR" = "X"	# {
    then
      LSOF_CDIR=`expr $LSOF_HOST : '\([^\.]*\)\..*$'`
      if test "X$LSOF_CDIR" = "X"	# {
      then
	LSOF_CDIR=$LSOF_HOST
      fi	# }
      LSOF_CDIR=`echo $LSOF_CDIR | tr a-z A-Z`
    else
      LSOF_CDIR=$DU_CDIR
    fi	# }
    LSOF_LOOP=1
    while test $LSOF_LOOP = 1	# {
    do
      if test -d ${DU_SYSDIR}/$LSOF_CDIR	# {
      then
	echo "Using header files in ${DU_SYSDIR}/$LSOF_CDIR"
	LSOF_LOOP=0
      else
	cat << .CAT_MARK

Please enter the name of the subdirectory in $DU_SYSDIR that contains the
configuration files for this host.  Usually its name would be $LSOF_CDIR, but
that subdirectory doesn't seem to exist.  The lsof compilation needs header
files specific to this machine's configuration found in that directory.

If you can't specify the appropriate configuration subdirectory, quit this
Configure step now and generate a proper configuration subdirectory with the
kernel generation process.

.CAT_MARK

	echo "$DU_SYSDIR contains:"
	echo ""
	ls -CF $DU_SYSDIR
	echo ""
	echo -n "Configuration subdirectory name? "
	read LSOF_CDIR LSOF_EXCESS
	if test "X$LSOF_CDIR" = "X" -o ! -d ${DU_SYSDIR}/$LSOF_CDIR	# {
	then
	  echo ""
	  echo Cannot access directory ${DU_SYSDIR}/$LSOF_CDIR.
	fi	# }
      fi	# }
    done	# }

    # Determine the ADVFS file system version.

    if test "X$DU_ADVFSV" = "X"	# {
    then
      echo "Determining the ADVFS version -- this will take a while."
      LSOF_ADVFSV=`/usr/sbin/setld -i | grep "^OSFADVFSBIN[0-9]" | sed 's/\([^ ]*\).*/\1/' | sort -u | tail -1 | sed 's/OSFADVFSBIN//'`
    else
      LSOF_ADVFSV=$DU_ADVFSV
    fi	# }
    case $LSOF_ADVFSV in	# {
    1*)
      LSOF_ADVFSV=100
      echo "The ADVFS version is 1."
      ;;
    2*)
      LSOF_ADVFSV=200
      echo "The ADVFS version is 2."
      ;;
    3*)
      LSOF_ADVFSV=300
      echo "The ADVFS version is 3."
      ;;
    4*)
      LSOF_ADVFSV=400
      echo "The ADVFS version is 4."
      ;;
    5*)
      LSOF_ADVFSV=500
      echo "The ADVFS version is 5."
      ;;
    *)
      echo "The ADVFS version is unknown; it will be assumed to be 1."
      LSOF_ADVFSV=100
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DDUV=$LSOF_VERS -DADVFSV=$LSOF_ADVFSV $LSOF_TMP2"
    if test "X$DU_SYSINC" = "X"	# {
    then
      DU_SYSINC="/usr/sys/include"
    fi	# }
    LSOF_DINC="$LSOF_DINC -I${DU_SYSDIR}/$LSOF_CDIR -I$DU_SYSINC"
    LSOF_CFGL="$LSOF_CFGL -lmld"
    if test "X${DU_SHLIB}" = "X"	# {
    then
      DU_SHLIB=/usr/shlib
    fi	# }
    if test -r ${DU_SHLIB}/libmsfs.so	# {
    then
      nm ${DU_SHLIB}/libmsfs.so | grep tag_to_path > /dev/null 2>&1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASTAGTOPATH"
	LSOF_CFGL="$LSOF_CFGL -lmsfs"
      fi	# }
    fi	# }
    grep "^struct spec_node {" ${DU_SYSDIR}/include/sys/specdev.h > /dev/null 2>&1
    if test $? -eq 0	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASSPECNODE"
    fi	# }
    if test $LSOF_VERS -ge 50000	# {
    then

    # Make du5_sys_malloc.h for DU 5.0 and above.  Enable strict ANSI checking
    # on 5.0 and 5.1A, but not 5.1B.  Enable IPv6 handling.

      LSOF_TMP1="-std1"
      if test $LSOF_VERS -ge 50100	# {
      then
	LSOF_TMP1="-std"
	if test -x /usr/sbin/sizer	# {
	then
	  /usr/sbin/sizer -v | grep -q 5.1A
	  if test $? -eq 0	# {
	  then
	    LSOF_TMP1="-std1"
	  fi	# }
	fi	# }
      fi	# }
      LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
      LSOF_TMP1=${LSOF_INCLUDE}/sys/malloc.h
      if test -r $LSOF_TMP1	# {
      then
	LSOF_TMP2=dialects/du/du5_sys_malloc.h
	rm -f $LSOF_TMP2
	echo "#if !defined(MANUFACTURED_DU5_SYS_MALLOC_H)" > $LSOF_TMP2
	echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP2
	echo "#define MANUFACTURED_DU5_SYS_MALLOC_H" >> $LSOF_TMP2
	grep "^#define[ 	]MALLOC_NUM_BUCKETS" $LSOF_TMP1 >> $LSOF_TMP2
	echo "struct percpukmembuckets {" >> $LSOF_TMP2
	sed '1,/^struct percpukmembuckets/d' $LSOF_TMP1 | sed -n '1,/^};/p' >> $LSOF_TMP2
	echo "#endif" >> $LSOF_TMP2
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/du"
      fi	# }

    # Enable IPv6 for Tru64 UNIX 5.0 and above.

      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/namei.h
    then
      grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
      fi	# }
    fi	# }
    LSOF_DIALECT_DIR=du
    ;;

# Configure for FreeBSD.

  freebsd)
    LSOF_FBSD_ZFS=0
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

    # If the FreeBSD version isn't pre-defined, determine it.

      case $LSOF_VSTR in	# {
      1.*)
	LSOF_VERS=1000
	;;
      2.0-*)
	LSOF_VERS=2000
	;;
      2.0.5-*)
	LSOF_VERS=2005
	;;
      2.1*)
	LSOF_VERS=2010
	;;
      2.2*)
	LSOF_VERS=2020
	;;
      3.0*)
	LSOF_VERS=3000
	;;
      3.1*)
	LSOF_VERS=3010
	;;
      3.2*)
	LSOF_VERS=3020
	;;
      3.3*)
	LSOF_VERS=3030
	;;
      3.4*)
	LSOF_VERS=3040
	;;
      3.5*)
	LSOF_VERS=3050
	;;
      3*)
	LSOF_VERS=3050
	echo "!!!WARNING!!!  Unsupported FreeBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for FreeBSD 3.5"
	;;
      4.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4000
	;;
      4.1-*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4010
	;;
      4.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4020
	;;
      4.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4030
	;;
      4.4*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4040
	;;
      4.5*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4050
	;;
      4.6*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4060
	;;
      4.7*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4070
	;;
      4.8*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4080
	;;
      4.9*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4090
	;;
      4.10*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4100
	;;
      4.11*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=4110
	;;
      4*)
	LSOF_VERS=4100
	echo "!!!WARNING!!!  Unsupported FreeBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for FreeBSD 4.10"
	;;
      5.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=5000
	;;
      5.1*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=5010
	;;
      5.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=5020
	;;
      5.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=5030
	;;
      5.4*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=5040
	;;
      5.5*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=5050
	;;
      5*)
	LSOF_VERS=5050
	echo "!!!WARNING!!!  Unsupported FreeBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for FreeBSD 5.5"
	;;
      6.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=6000
	;;
      6.1*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=6010
	;;
      6.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=6020
	;;
      6.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=6030
	;;
      6.4*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=6040
	;;
      6*)
	LSOF_VERS=6000
	echo "!!!WARNING!!!  Unsupported FreeBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for FreeBSD 6.0"
	;;
      7.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7000
	;;
      7.1*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7010
	;;
      7.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7020
	;;
      7.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7030
	;;
      7.4*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=7040
	;;
      7*)
	LSOF_VERS=7000
	echo "!!!WARNING!!!  Unsupported FreeBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for FreeBSD 7.0"
	;;
      8.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=8000
	;;
      8.1*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=8010
	;;
      8.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=8020
	;;
      8.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=8030
	;;
      9*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=9000
	;;
      10*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=10000
	;;
      *)
	echo Unknown FreeBSD release: `uname -r`
	rm -f $LSOF_HLP
	exit 1
	;;
      esac	# }
    fi	# }

    # Clear LSOF_UNSUP message for supported versions of FreeBSD.
    
    case $LSOF_VERS in  # {
    4090|8020|8030|9000|10000)
      LSOF_UNSUP=""
      ;;
    esac	# }

    # Get system CFLAGS from FREEBSD_MAKE_CONF (default=/etc/make.conf).

    if test "X$FREEBSD_MAKE_CONF" = "X"	# {
    then
      FREEBSD_MAKE_CONF="/etc/make.conf"
    fi	# }
    if test -r $FREEBSD_MAKE_CONF	# {
    then
      LSOF_TMP1=`echo "all:\n.include <bsd.prog.mk>" | $LSOF_MAKE -f- -VCFLAGS`
      LSOF_TMP=1
      while test $LSOF_TMP -eq 1	# {
      do
	echo $LSOF_TMP1 | grep -q -e '-O'
	if test $? -eq 0	# {
	then
	  if test "X$LSOF_DEBUG" = "X"
	  then	# {
	    LSOF_DEBUG=`echo $LSOF_TMP1 | sed 's/.*\(-O[^ $]*\).*/\1/'`
	  fi	# }
	  LSOF_TMP1=`echo $LSOF_TMP1 | sed 's/\(.*\)-O[^ $]*\(.*\)/\1 \2/' | sed 's/^  *//g' | sed 's/  */ /g' | sed 's/  *$//'`
	else
	  LSOF_TMP=0
	fi	# }
	LSOF_FBSD_ZFS_CFGF="$LSOF_CFGF $LSOF_TMP1"
      done	# }
      LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
    fi	# }

    # Determine path to FreeBSD sources.

    LSOF_DINC_ADD=0
    if test "X$FREEBSD_SYS" = "X"	# {
    then
      if test -d /usr/src/sys	# {
      then
	FREEBSD_SYS=/usr/src/sys
      else
	if test -d /sys	# {
	then
	  FREEBSD_SYS="/sys"
	else
	  echo "!!!WARNING!!!  No kernel sources in /usr/src/sys or /sys"
	fi	# }
      fi	# }
    fi	# }

    # Do FreeBSD version-specific stuff.

    case $LSOF_VERS in	# {
    1000)
      LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
      LSOF_CFGL="$LSOF_CFGL -lutil"
      LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/freebsd/include"
      if test "X$FREEBSD_KERNEL" = "X"	# {
      then
	LSOF_N_UNIXV="/386bsd"
      else
	LSOF_N_UNIXV=$FREEBSD_KERNEL
      fi	# }
      ;;
    2000|2005|2010)
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      ;;
    2020)
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      if test -r ${LSOF_INCLUDE}/vm/lock.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH"
      fi	# }
      ;;
    3000|3010|3020|3030|3040|3050)
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H"
      fi	# }
      if test -r ${LSOF_INCLUDE}/vm/lock.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH"
      fi	# }
      ;;
    *)
      if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H"
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/namei.h	# {
      then
	grep -q "^struct[ 	]*namecache[ 	]*{" ${LSOF_INCLUDE}/sys/namei.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASNAMECACHE"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h	# {
      then
	grep -q i_effnlink ${LSOF_INCLUDE}/ufs/ufs/inode.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASEFFNLINK=i_effnlink"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/file.h	# {
      then
	grep -q f_vnode ${LSOF_INCLUDE}/sys/file.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASF_VNODE"
	fi	# }
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lkvm"
      if test $LSOF_VERS -ge 5000	# {
      then

      # Do FreeBSD 5 and higher version-specific stuff.

	if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	then
	  grep VT_FDESC ${LSOF_INCLUDE}/sys/vnode.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    if test ! -r ${LSOF_INCLUDE}/fs/devfs/devfs.h	# {
	    then
	      if test -r ${FREEBSD_SYS}/fs/devfs/devfs.h	# {
	      then
		LSOF_DINC_ADD=1
	      else
		echo "!!!FATAL: lsof cannot locate the devfs.h header file"
		echo "          in ${LSOF_INCLUDE}/fs/devfs/devfs.h or"
		echo "          ${FREEBSD_SYS}/fs/devfs/devfs.h.  Consult"
		echo "          00FAQ for an explanation."
		rm -f $LSOF_HLP
		exit 1
	      fi	# }
	    fi	# }
	  fi	# }
	fi	# }

      # Do FreeBSD 5.2 and higher version-specific stuff.

	if test $LSOF_VERS -ge 5020	# {
	then

	# Determine the status of the cpumask_t typedef.

	  rm -f ${LSOF_TMPC}.*
	  cat > ${LSOF_TMPC}.c << .LSOF_END_HERE_DOC3
#undef _KERNEL
#include <sys/types.h>
main() {
cpumask_t c;
}
.LSOF_END_HERE_DOC3
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
	  LSOF_TMP1=$?
	  rm -f ${LSOF_TMPC}.*
	  if test $LSOF_TMP1 -ne 0	# {
	  then

	  # The cpumask_t typedef is unknown when _KERNEL is not defined.

	    if test -r ${LSOF_INCLUDE}/sys/types.h \
		    -a -r ${LSOF_INCLUDE}/machine/_types.h	# {
	    then
	      grep -q cpumask_t ${LSOF_INCLUDE}/sys/types.h
	      if test $? -eq 0	# {
	      then
	        grep -q __cpumask_t ${LSOF_INCLUDE}/machine/_types.h
	        if test $? -eq 0	# {
	        then
		  LSOF_CFGF="$LSOF_CFGF -DHASCPUMASK_T"
	        else
		  $LSOF_CC -E ${LSOF_INCLUDE}/machine/_types.h 2>/dev/null | grep -q __cpumask_t
		  if test $? -eq 0  # {
		  then
		    LSOF_CFGF="$LSOF_CFGF -DHASCPUMASK_T"
		  fi	# }
	        fi	# }
	      fi	# }
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/socketvar.h	# {
	  then
	    grep -q SBS_CANT ${LSOF_INCLUDE}/sys/socketvar.h
	    if test $? -eq 0	# {
	    then
		LSOF_CFGF="$LSOF_CFGF -DHASSBSTATE"
	    fi	# }
	  fi	# }
	fi	# }
	if test $LSOF_VERS -ge 5030	# {
	then

	# Do FreeBSD 5.3 and higher version-specific stuff.

	  if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	  then
	    grep -q "defined(_KVM_VNODE)" ${LSOF_INCLUDE}/sys/vnode.h
	    if test $? -eq 0	# {
	    then
		LSOF_CFGF="$LSOF_CFGF -DHAS_KVM_VNODE"
	    fi	#}
	  fi	# }
	fi	# }
	if test $LSOF_VERS -ge 6000	# {
	then

	# Do FreeBSD 6.0 and higher version-specific stuff.

	  if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h	# {
	  then
	    grep -q i_din2 ${LSOF_INCLUDE}/ufs/ufs/inode.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_UFS1_2"
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/conf.h	# {
	  then
	    grep -q vm_memattr_t ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -eq 0	#{
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_VM_MEMATTR_T"
	    fi	# }
	    grep -q "^#define	minor(" ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_CONF_MINOR"
	      rm -f fbsd_minor.h
	      if test -r ${LSOF_INCLUDE}/sys/types.h	# {
	      then
		LSOF_TMP1=`grep "^#define[ 	]minor(" ${LSOF_INCLUDE}/sys/types.h`
		if test "X$LSOF_TMP1" != "X"	# {
		then
		  echo "Creating fbsd_minor.h"
		  cat > fbsd_minor.h << FBSD_MINOR1
/*
 * fbsd_minor.h -- created by lsof Configure script on
FBSD_MINOR1
		  echo $EO " * $EC" >> ./fbsd_minor.h
		  date >> ./fbsd_minor.h
		  cat >> ./fbsd_minor.h << FBSD_MINOR2
 */

#if	!defined(FBSD_MINOR_H)
#define	FBSD_MINOR_H

FBSD_MINOR2
		  echo $EO "${LSOF_TMP1}${EC}" >> fbsd_minor.h
		  cat >> ./fbsd_minor.h << FBSD_MINOR3

#endif	/* defined(FBSD_MINOR_H) */
FBSD_MINOR3
		fi	# }
	      fi	# }
	    else
	      if test -r ${FREEBSD_SYS}/fs/devfs/devfs_int.h	# {
	      then
		grep -q cdev2priv ${FREEBSD_SYS}/fs/devfs/devfs_int.h
		if test $? -eq 0	# {
		then
		  LSOF_CFGF="$LSOF_CFGF -DHAS_CDEV2PRIV"
		fi	# }
	      fi	# }
	    fi	# }
	    grep -q "si_udev;" ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -ne 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_NO_SI_UDEV"
	    fi	# }
	    grep -q si_priv ${LSOF_INCLUDE}/sys/conf.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_SI_PRIV"
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/sx.h	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_SX_H"
	  fi	# }

	# Do ZFS test.  Try for the newer OpenSolaris files first -- i.e.,
	# the ones in ${FREEBSD_SYS}/cddl/contrib/opensolaris.  If that fails,
	# try for the older ones in ${FREEBSD}/contrib/opensolaris.

	  LSOF_FBSD_ZFS_SYS=${FREEBSD_SYS}/cddl
	  if test ! -r ${LSOF_FBSD_ZFS_SYS}/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h	# {
	  then
	    LSOF_FBSD_ZFS_SYS=${FREEBSD_SYS}
	    if test ! -r ${LSOF_FBSD_ZFS_SYS}/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h	# {
	    then
	      LSOF_FBSD_ZFS_SYS=""
	    fi	# }
	  fi	# }
	  if test "X$LSOF_FBSD_ZFS_SYS" != "X"	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_ZFS"
	    LSOF_FBSD_ZFS=1
	    LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DFREEBSDV=$LSOF_VERS"
	    LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_ZFS"
	    grep -q z_phys ${LSOF_FBSD_ZFS_SYS}/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
	    if test $? -eq 0	# {
	    then
	      LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_Z_PHYS"
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	  then

	  # See if the vnode contains the byte level lock pointer.

	    grep -q v_lockf ${LSOF_INCLUDE}/sys/vnode.h
	    if test $? -eq 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHAS_V_LOCKF"
	      if test $LSOF_FBSD_ZFS -eq 1	# {
	      then
	        LSOF_FBSD_ZFS_CFGF="$LSOF_FBSD_ZFS_CFGF -DHAS_V_LOCKF"
	      fi	# }
	    fi	# }
	  fi	# }
	  if test -r ${LSOF_INCLUDE}/sys/lockf.h	# {
	  then

	  # Determine the type of locking structure to which the inode or
	  # vnode points.

	    grep -q "^struct lockf_entry" ${LSOF_INCLUDE}/sys/lockf.h
	    if test $? -eq 0	# {
	    then

	    # Build the ./lockf_owner.h header file.

	      LSOF_TMP1=""
	      LSOF_TMP2=0
	      echo "Creating ./lockf_owner.h from ${FREEBSD_SYS}/kern/kern_lockf.c"
	      rm -f ./lockf_owner.h
	      if test -r ${FREEBSD_SYS}/kern/kern_lockf.c	# {
	      then
		LSOF_TMP1=`grep -n "^struct lock_owner" ${FREEBSD_SYS}/kern/kern_lockf.c | sed 's/\([0-9]*\):.*$/\1/'`
		if test "X$LSOF_TMP1" != "X"	# {
		then
		  LSOF_TMP2=0
		  for i in `grep -n "};" ${FREEBSD_SYS}/kern/kern_lockf.c | sed 's/\([0-9]*\):.*$/\1/'` # {
		  do
		    if test $LSOF_TMP2 -eq 0 -a $i -gt $LSOF_TMP1	# {
		    then
		      LSOF_TMP2=$i
		    fi	# }
		  done	# }
		  if test $LSOF_TMP2 -eq 0	# {
		  then
		    LSOF_TMP1=""
		  else
		    cat > ./lockf_owner.h << LOCKF_OWNER1
/*
 * lockf_owner.h -- created by lsof Configure script on
LOCKF_OWNER1
		    echo $EO " * $EC" >> ./lockf_owner.h
		    date >> ./lockf_owner.h
		    cat >> ./lockf_owner.h << LOCKF_OWNER2
 */

#if	!defined(LOCKF_OWNER_H)
#define	LOCKF_OWNER_H

LOCKF_OWNER2
		    ed -s ${FREEBSD_SYS}/kern/kern_lockf.c >> ./lockf_owner.h << LOCKF_OWNER3
${LSOF_TMP1},${LSOF_TMP2}p
LOCKF_OWNER3
		    if test $? -ne 0	# {
		    then
		      LSOF_TMP1=""
		    else
		      cat >> ./lockf_owner.h << LOCKF_OWNER4

#endif	/* defined(LOCKF_OWNER_H) */
LOCKF_OWNER4
		    fi	# }
		  fi	# }
		fi	# }
	      else
		echo "FATAL ERROR: can't read ${FREEBSD_SYS}/kern/kern_lockf.c"
	      fi	# }
	      if test "X$LSOF_TMP1" != "X" -a "X$LSOF_TMP2" != "X0" # {
	      then
		echo "./lockf_owner.h creation succeeded."
	        LSOF_CFGF="$LSOF_CFGF -DHAS_LOCKF_ENTRY"
	      else
		echo "FATAL ERROR: ./lockf_owner.h creation failed (see 00FAQ)"
		rm -f $LSOF_HLP
		exit 1
	      fi	# }
	    fi	# }

	  # Test for in6p_.port in inpcb structure.

	    if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h	# {
	    then
	      grep -q 'in6p_.port' ${LSOF_INCLUDE}/netinet/in_pcb.h
	      if test $? -ne 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHAS_NO_6PORT"
	      fi	# }
	    fi	# }

	  # Test for in6p_ppcb in inpcb structure.

	    if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h	# {
	    then
	      grep -q 'in6p_ppcb' ${LSOF_INCLUDE}/netinet/in_pcb.h
	      if test $? -ne 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DHAS_NO_6PPCB"
	      fi	# }
	    fi	# }
	    if test -r ${LSOF_INCLUDE}/sys/conf.h	# {
	    then
	      grep -q 'doadump(boolean_t)' ${LSOF_INCLUDE}/sys/conf.h
	      if test $? -eq 0	# {
	      then
		LSOF_CFGF="$LSOF_CFGF -DNEEDS_BOOLEAN_T"
	      fi	# }
	    fi	# |
	  fi	# }
	fi	# }
      fi	# }
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DFREEBSDV=$LSOF_VERS"
    if test $LSOF_VERS -lt 2000 -a "X$FREEBSD_KERNEL" = "X"	# {
    then
      if test ! -x $LSOF_N_UNIXV	# {
      then
	echo "Hmmm -- $LSOF_N_UNIXV doesn't appear to be your kernel file."
	echo "Please enter the name of the file in / that contains"
	echo "the kernel for this host.  It must be a regular file,"
	echo "not a directory, and must be executable."
	LSOF_LOOP=1
	while test $LSOF_LOOP = 1	# {
	do
	  echo ""
	  echo "/ contains:"
	  echo ""
	  ls -CF /
	  echo ""
	  echo -n "Kernel file name? "
	  read LSOF_N_UNIXV LSOF_EXCESS
	  LSOF_N_UNIXV="/$LSOF_N_UNIXV"
	  if test ! -d $LSOF_N_UNIXV -a -x $LSOF_N_UNIXV	# {
	  then
	    LSOF_LOOP=0
	  else
	    echo ""
	    echo $LSOF_N_UNIXV is not a regular executable file.
	  fi	# }
	done	# }
      fi	# }
      LSOF_N_UNIXV=`echo $LSOF_N_UNIXV | sed 's#^/*#/#'`
      LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=$LSOF_N_UNIXV"
    fi	# }
    if test -r ${FREEBSD_SYS}/miscfs/fdesc/fdesc.h	# {
    then
      LSOF_TMP1=${FREEBSD_SYS}/miscfs/fdesc/fdesc.h
    else
      if test $LSOF_VERS -ge 5000 -a -r ${LSOF_INCLUDE}/fs/fdescfs/fdesc.h  # {
      then
	LSOF_TMP1=${LSOF_INCLUDE}/fs/fdescfs/fdesc.h
      else
	LSOF_TMP1=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP1" != "X"	# {
    then
      grep -q Fctty $LSOF_TMP1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=1"
      else
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=2"
      fi	# }
      grep -q fd_link $LSOF_TMP1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDLINK"
      fi	# }
      LSOF_DINC_ADD=1
    fi	# }
    if test $LSOF_VERS -ge 5000	# {
    then
      LSOF_TMP1="fs"
    else
      LSOF_TMP1="miscfs"
    fi	# }
    if test $LSOF_VERS -lt 5000	# {
      then
      if test -d ${FREEBSD_SYS}/${LSOF_TMP1}/procfs	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
	LSOF_DINC_ADD=1
      fi	# }
    else
      if test -d ${FREEBSD_SYS}/${LSOF_TMP1}/pseudofs	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASPSEUDOFS"
	LSOF_DINC_ADD=1
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/${LSOF_TMP1}/nullfs/null.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
    else
      if test -r ${FREEBSD_SYS}/${LSOF_TMP1}/nullfs/null.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
	LSOF_DINC_ADD=1
      fi	# }
    fi	# }
    if test -r ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h	# {
    then
      rm -f cd9660_node.h
      grep -q "^#ifdef [_]*KERNEL" ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h
      if test $? -eq 0	# {
      then
	ln -s ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h cd9660_node.h
      else
	sed -e '/^ \* Prototypes for ISOFS vnode operations/,$c\
	\ The ISOFS prototypes were removed by Configure. */' \
	< ${FREEBSD_SYS}/isofs/cd9660/cd9660_node.h > cd9660_node.h
	echo "" >> cd9660_node.h
      fi	# }
      LSOF_CFGF="$LSOF_CFGF -DHAS9660FS"
      if test $LSOF_VERS -ge 6000	# {
      then
	grep -q "i_dev;" cd9660_node.h
	if test $? -ne 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_NO_ISO_DEV"
	fi	# }
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/namei.h
    then
      grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
      fi	# }
    fi	# }
    if test $LSOF_DINC_ADD -eq 1	# {
    then
      if test "X$LSOF_DINC" = "X"	# {
      then
	LSOF_DINC="-I${FREEBSD_SYS}"
      else
	LSOF_DINC="$LSOF_DINC -I${LSOF_INCLUDE} -I${FREEBSD_SYS}"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/netinet/in.h	# {
    then
      grep IPV6_INRIA_VERSION ${LSOF_INCLUDE}/netinet/in.h > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6"
      fi	# }
    fi	# }
    echo $CFGF | grep HASIPv6 > /dev/null
    if test $? -ne 0 -a -r ${LSOF_INCLUDE}/netinet6/in6.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }
    if test -r ${LSOF_INCLUDE}/utmpx.h # {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASUTMPX"
    fi	# }
    LSOF_DIALECT_DIR=freebsd
    ;;

# Configure for HP-UX and HP-UX gcc.

  hpux|hpuxgcc)
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the HP-UX version isn't pre-defined, determine it.

      LSOF_VERS=`echo $LSOF_VSTR | awk -F. '{printf "%d%02d",\$2,\$3}'`
    fi	# }
    if test $LSOF_VERS -ge 1020	# {
    then
      LSOF_TSTBIGF="-D_LARGEFILE64_SOURCE"
    fi	# }

    # Determine compiler.

    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xhpuxgcc"	# {
      then
	LSOF_CC=gcc
      else
	if test "X$HPUX_CCDIR1" = "X"	# {
	then
	  HPUX_CCDIR1="/bin"
	fi	# }
	if test "X$HPUX_CCDIR2" = "X"	# {
	then
	  HPUX_CCDIR2="/usr/ccs/bin"
	fi	# }
	if test -x ${HPUX_CCDIR1}/cc	# {
	then
	  LSOF_CC=${HPUX_CCDIR1}/cc
	else
	  if test -x ${HPUX_CCDIR2}/cc	# {
	  then
	    LSOF_CC=${HPUX_CCDIR2}/cc
	  else
	    echo "No executable cc in $HPUX_CCDIR1 or $HPUX_CCDIR2"
	    rm -f $LSOF_HLP
	    exit 1
	  fi	# }
	fi	# }
	$LSOF_CC -O < /dev/null 2>&1 | grep -q Bundled
	if test $? -eq 0	# {
	then
	  LSOF_DEBUG="No-O"			# to disable -O
	  if test "X$HPUX_LIBC1" = "X"	# {
	  then
	    HPUX_LIBC1="/usr/lib"
	  fi	# }
	  if test -r ${HPUX_LIBC1}/libc.sl	# {
	  then
	    LSOF_FCFGL="-L$HPUX_LIBC -lc"
	  else
	    if test "X$HPUX_LIBC2" = "X"	# {
	    then
	      HPUX_LIBC2="/usr/lib"
	    fi	# }
	    if test -r ${HPUX_LIBC2}/libc.sl	# {
	    then
	      LSOF_FCFGL="-L$HPUX_LIBC2 -lc"
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
    fi	# }
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0	# {
    then
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    else
      $LSOF_CC -O < /dev/null 2>&1 | grep -q Bundled
      if test $? -eq 0	# {
      then
	LSOF_DEBUG="No-O"			# to disable -O
      fi	# }
    fi	# }
    LSOF_TGT=hpux

    # Test for "const void" support.

    rm -f ${LSOF_TMPC}.*
    echo "main() { const void *x; return(0); }" >> $LSOF_TMPC.c
    $LSOF_CC $LSOF_TMPC.c -o $LSOF_TMPC.x > /dev/null 2>&1
    if test $? -eq 0	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_CONST"
    fi	# }
    rm -f ${LSOF_TMPC}.*

    # Test HP-UX base.

    if test "X$HPUX_BASE" = "X"	# {
    then
      if test -d $LSOF_INCLUDE/sys/pstat -a $LSOF_VERS -ge 1111 	# {
      then
	HPUX_BASE="pstat"
      else
	HPUX_BASE="/dev/kmem"
      fi	# }
    fi	# }
    if test "X$HPUX_BASE" = "Xpstat"	# {
    then

      # Configure for pstat-based HP-UX lsof.

      LSOF_CINFO="PSTAT-based"
      echo "Configuring PSTAT-based HP-UX lsof"
      LSOF_DIALECT_DIR=hpux/pstat
      LSOF_CFGF="$LSOF_CFGF -DHPUXV=$LSOF_VERS -D_PSTAT64"
      LSOF_CFGL="$LSOF_CFGL -lnsl"
      LSOF_TSTKMEM=0
      LSOF_TSTK64=1
      ls -l $LSOF_CC | grep -q ansic
      LSOF_TMP1=$?
      ls -l $LSOF_CC | grep -q aCC
      if test $? -eq 0 -o $LSOF_TMP1 -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -Ae +DD32"
      else
	echo $LSOF_CC | grep -q gcc
	if test $? -ne 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF +DD32"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/netinet/in6.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/pstat/stream_pstat_body.h	# {
      then
	grep -q PS_STR_XPORT_DATA ${LSOF_INCLUDE}/sys/pstat/stream_pstat_body.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -D_PSTAT_STREAM_GET_XPORT"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 1123	# {
      then
	LSOF_CFGF="$LSOF_CFGF -D_LARGEFILE64_SOURCE"
      fi	# }
    else
      if test "X$HPUX_BASE" = "X/dev/kmem"	# {
      then
    
	# Configure for /dev/kmem-based HP-UX lsof.

	if test "X$HPUX_BOOTFILE" = "X"	# {
	then
	  HPUX_BOOTFILE="/stand/vmunix"
	fi	# }
	if test $LSOF_VERS -gt 1100	# {
	then
	  echo ""
	  echo "************************************************"
	  echo "*                                              *"
	  echo "* !!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!! *"
	  echo "*                                              *"
	  echo "* LSOF DOES NOT SUPPORT THIS VERSION OF HP-UX. *"
	  echo "*                                              *"
	  echo "************************************************"
	  echo ""
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	LSOF_CFGF="$LSOF_CFGF -DHPUXV=$LSOF_VERS"
	LSOF_CINFO="/dev/kmem-based"
	LSOF_DIALECT_DIR=hpux/kmem
	echo "Configuring /dev/kmem-based HP-UX lsof"
	if test $LSOF_VERS -lt 1000	# {
	then
	  if test "X$HPUX_X25DIR" = "X"	# {
	  then
	    HPUX_X25DIR="/etc/conf"
	  else
	    HPUX_X25DIR=$HPUX_X25DIR
	  fi	# }
	  if test -r ${HPUX_X25DIR}/x25/x25addrstr.h	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHPUX_CCITT"
	    LSOF_DINC="$LSOF_DINC -I$HPUX_X25DIR"
	  fi	# }
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h -a -r ${LSOF_INCLUDE}/sys/fs/vx_hpux.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
	fi	# }
	if test $LSOF_VERS -ge 1030	# {
	then
	  if test "X$HPUX_KERNBITS" = "X"	# {
	  then
	    HPUX_KERNBITS=`getconf _SC_KERNEL_BITS`
	  fi	# }
	  LSOF_CFGF="$LSOF_CFGF -DHPUXKERNBITS=${HPUX_KERNBITS} -I`pwd`/dialects/hpux/kmem/hpux11"
	  if test $HPUX_KERNBITS -eq 64	# {
	  then
	    LSOF_TSTK64=1
	    echo ""
	    echo "*****************************************"
	    echo "*                                       *"
	    echo "* NOTICE!  Configuring for 64 bit HP-UX *"
	    echo "*                                       *"
	    echo "*****************************************"
	    echo $LSOF_CC | grep gcc > /dev/null
	    if test $? -eq 0	# {
	    then

	    # Test gcc for 64 bit support, trying gcc with no options, then
	    # with -mlp64, testing the result with file.

	      echo ""
	      echo "Testing $LSOF_CC for 64 bit support"
	      rm -f ${LSOF_TMPC}.*
	      echo "main(){}" > ${LSOF_TMPC}.c
	      LSOF_TMP1=""
	      $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
	      if test $? -eq 0	# {
	      then
		/bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
		if test $? -eq 0	# {
		then
		    LSOF_TMP1=" "
		fi	# }
	      fi	# }
	      if test "X$LSOF_TMP1" = "X"	# {
	      then
		rm -f ${LSOF_TMPC}.x
		$LSOF_CC ${LSOF_TMPC}.c -mlp64 -o ${LSOF_TMPC}.x > /dev/null 2>&1
		if test $? -eq 0	# {
		then
		  /bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null
		  if test $? -eq 0	# {
		  then
		      LSOF_TMP1="-mlp64"
		  fi	# }
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.*
	      if test "X$LSOF_TMP1" = "X"	# {
	      then
		echo ""
		echo "***************************************************"
		echo "*                                                 *"
		echo "* !!!!!!!!!!!!!!!!! FATAL ERROR !!!!!!!!!!!!!!!!! *"
		echo "*                                                 *"
		echo "* APPARENTLY GCC CANNOT BUILD 64 BIT EXECUTABLES. *"
		echo "* A COMPILER MUST BE USED THAT CAN.  SEE 00FAQ    *"
		echo "* FOR MORE INFORMATION.                           *"
		echo "*                                                 *"
		echo "***************************************************"
		echo ""
		rm -f $LSOF_HLP
		exit 1
	      else
		if test "X$LSOF_TMP1" != "X "	# {
		then
		  LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
		fi	# }
		LSOF_CFGL="$LSOF_CFGL -lelf"
		LSOF_CINFO="${LSOF_CINFO}, 64 bit HP-UX"
	      fi	# }
	    else

	    # Set options for the HP-UX compiler.

	      LSOF_CFGF="$LSOF_CFGF +DD64"
	      LSOF_CFGL="$LSOF_CFGL -lelf"
	      LSOF_CINFO="${LSOF_CINFO}, 64 bit HP-UX"
	    fi	# }
	  else
	    LSOF_CFGF="$LSOF_CFGF -D_FILE_OFFSET_BITS=64"
	    LSOF_CINFO="${LSOF_CINFO}, 32 bit HP-UX"
	    echo $LSOF_CC | grep gcc > /dev/null
	    if test $? -ne 0	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF +DAportable"
	    fi	# }
	  fi	# }
	  LSOF_CFGL="$LSOF_CFGL -lnsl"
	else

	# When HP-UX is less than 10.30, but greater than or equal to 10,
	# check NFS3 rnode status.

	  if test $LSOF_VERS -ge 1000	# {
	  then
	    LSOF_TMP1=0
	    if test "X$HPUX_RNODE3" = "X"	# {
	    then
	      nm -x $HPUX_BOOTFILE | grep -q nfs_vnodeops3
	      if test $? -eq 0	# {
	      then
		if test -r ${LSOF_INCLUDE}/nfs/rnode.h	# {
		then
		  grep -q r_fh3 ${LSOF_INCLUDE}/nfs/rnode.h
		  if test $? -ne 0	# {
		  then
		    LSOF_TMP1=1
		  fi	# }
		fi	# }
	      fi	# }
	    else
	      if test "X$HPUX_RNODE3" = "X1"	# {
	      then
		LSOF_TMP1=1
	      fi	# }
	    fi	# }
	    if test $LSOF_TMP1 -eq 1	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHASRNODE3"
	    fi	# }
	  fi # }
	fi	# }
	if test $LSOF_VERS -eq 1100	# {
	then

	# Test for the ipis_s structure.  If it is present, set HAS_IPC_S_PATCH.

	  if test "X$HPUX_IPC_S_PATCH" = "X"	# {
	  then
	    if test -x /usr/contrib/Q4/bin/q4exe	# {
	    then
	      LSOF_TMP=/usr/contrib/Q4/bin/q4exe
	    else
	      LSOF_TMP=/usr/contrib/bin/q4
	    fi	# }
	    if test -x $LSOF_TMP	# {
	    then
	      rm -f ${LSOF_TMPC}.out
	      echo ""
	      echo $EO "Looking in $HPUX_BOOTFILE for ipis_s with $LSOF_TMP ... $EC"
	      echo "yes\\nfields -c struct ipis_s" | $LSOF_TMP $HPUX_BOOTFILE > ${LSOF_TMPC}.out 2>&1
	      if test $? -ne 0	# {
	      then
		echo ""
		echo ""
		echo "!!!ERROR!!! $LSOF_TMP failed and produced the following output."
		echo ""
		cat ${LSOF_TMPC}.out
		HPUX_IPC_S_PATCH=fail
	      else
		grep ipis_s ${LSOF_TMPC}.out > /dev/null 2>&1
		if test $? -eq 0	# {
		then
		  echo "ipis_s exists."

		# See if ipis_msgsqueued is present.

		  grep ipis_msgsqueued ${LSOF_TMPC}.out > /dev/null 2>&1
		  if test $? -eq 0	# {
		  then
		    HPUX_IPC_S_PATCH=2
		  else
		    HPUX_IPC_S_PATCH=1
		  fi	# }
		else
		  echo "ipis_s doesn't exist."
		  HPUX_IPC_S_PATCH=N
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.out
	    else
	      echo "Can't locate or execute $LSOF_TMP"
	      echo $EO "ls says: $EC"
	      ls -ld $LSOF_TMP
	      HPUX_IPC_S_PATCH=fail
	    fi	# }
	  fi	# }
	  if test "X$HPUX_IPC_S_PATCH" = "Xfail"	# {
	  then
	    echo ""
	    echo "!!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!"
	    echo "Configure can't use $LSOF_TMP to examine the ipis_s"
	    echo "structure.  You must do that yourself, report the result in"
	    echo "the HPUX_IPC_S_PATCH environment variable, then repeat the"
	    echo "Configure step.  Consult the Configure script's use of"
	    echo "$LSOF_TMP and the 00XCONFIG file for information"
	    echo "on ipis_s testing and the setting of HPUX_IPC_S_PATCH."
	    echo "!!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!     !!!ERROR!!!"
	    echo ""
	    rm -f $LSOF_HLP
	    exit 1
	  fi	# }
	  if test "X$HPUX_IPC_S_PATCH" = "X1" -o "X$HPUX_IPC_S_PATCH" = "X2" # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_IPC_S_PATCH=$HPUX_IPC_S_PATCH"
	  else
	    if test "X$HPUX_IPC_S_PATCH" != "Xn" -a "X$HPUX_IPC_S_PATCH" != "XN" # {
	    then
	      echo "Illegal value for HPUX_IPC_S_PATCH: $HPUX_IPC_S_PATCH"
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	  fi	# }
	fi	#}

	# Manufacture an hpux_mount.h header file with a mount struct in it, as
	# required.

	if test -r ${LSOF_INCLUDE}/sys/mount.h	# {
	then
	  LSOF_TMP1="dialects/${LSOF_DIALECT_DIR}/hpux_mount.h"
	  rm -f $LSOF_TMP1
	  echo "#if !defined(MANUFACTURED_HPUX_SYS_MOUNT_H)" > $LSOF_TMP1
	  echo "#define MANUFACTURED_HPUX_SYS_MOUNT_H" >> $LSOF_TMP1
	  echo "/* By lsof Configure:" `date` " */" >> $LSOF_TMP1
	  echo "struct mount" >> $LSOF_TMP1
	  sed '1,/struct mount/d' ${LSOF_INCLUDE}/sys/mount.h | sed -n '1,/m_dev/p' >> $LSOF_TMP1
	  echo "};" >> $LSOF_TMP1
	  echo "#endif" >> $LSOF_TMP1
	  LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/${LSOF_DIALECT_DIR}"
	fi	# }

	# Test for OnlineJFS.

	if test $LSOF_VERS -ge 1100	# {
	then
	  if test "X$HPUX_HASONLINEJFS" = "X" -a -x /sbin/fs/vxfs/subtype  # {
	  then
	    LSOF_TMP1=`/sbin/fs/vxfs/subtype`
	    if test "X$LSOF_TMP1" = "Xvxfs3.3"
	    then
	      HPUX_HASONLINEJFS="Y"
	    fi	# }
	  fi	# }
	  if test "X$HPUX_HASONLINEJFS" = "XY" -o "X$HPUX_HASONLINEJFS" = "Xy"
	  # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASONLINEJFS"
	  fi	# }
	fi	# }

	# Test for AFS.

	if test -r ${AFS_VICE}/etc/ThisCell	# {
	then
	  if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
	  then
	    if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  else
	    if test ! -x ./AFSConfig	# {
	    then
	      echo "Can't find or execute the AFSConfig script"
	      rm -f $LSOF_HLP
	      exit 1
	    fi	# }
	    ./AFSConfig
	    if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	    then
	      LSOF_AFS="yes"
	    fi	# }
	  fi	# }
	  if test "X$LSOF_AFS" = "Xyes"	# {
	  then
	    LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	    LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	    LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
	  fi	# }
	fi	# }
      else
	echo "HP-UX base unrecognized: $HPUX_BASE"
	rm -f $LSOF_HLP
	exit 1
      fi	# }
    fi	# }
    ;;

# Configure for Linux.

  linux)
    LSOF_TSTBIGF="-D_FILE_OFFSET_BITS=64"
    LSOF_TSTKMEM=0
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LINUX_CONF_CC" = "X"	# {
    then
      LINUX_CONF_CC=$LSOF_CC
    fi	#}
    LSOF_DIALECT_DIR=""
    if test "X$LINUX_INCL" = "X" # {
    then
      LINUX_INCL=/usr/include
    else
      LSOF_DINC="$LSOF_DINC -I${LINUX_INCL}"
    fi	# }
    if test "X$LINUX_VERSION_CODE" = "X" # {
    then
      if test -r "$LINUX_INCL/linux/version.h" # {
      then
        LINUX_VERSION_CODE=`cat $LINUX_INCL/linux/version.h | sed -n 's/.\+LINUX_VERSION_CODE \([[:digit:]]\+\)$/\1/p'`
      fi # }
    fi # }
    LSOF_VSTR=`echo $LINUX_VERSION_CODE | perl -e '$version=<STDIN>; chomp($version); printf("%d.%d.%d\n", ($version >> 16) & 0xFF, ($version >> 8) & 0xFF, $version & 0xFF);'`
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the Linux version isn't predefined, determine it.

      LSOF_VERS=`echo $LSOF_VSTR | sed 's/\./ /g' | awk '{printf "%d%d%03d",\$1,\$2,\$3}'`
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DLINUXV=$LSOF_VERS"
    if test $LSOF_VERS -lt 21072	# {
    then
      echo ""
	echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!"
	echo "!                                                        !"
	echo "! THE /PROC-BASED LSOF SOURCES HAVE NOT BEEN TESTED ON   !"
	echo "! LINUX KERNELS BELOW 2.1.72, AND MAY NOT WORK ON THIS   !"
	echo "! KERNEL.  IT SHOULD USE A /DEV/KMEM-BASED LSOF.         !"
	echo "!                                                        !"
	echo "!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!==!!!WARNING!!!"
	echo ""
    else
      LSOF_UNSUP=""
    fi	# }

    # If the Linux C library type isn't predefined, determine it.

    if test "X$LINUX_CLIB" = "X"	# {
    then
      echo -n "Testing C library type with $LINUX_CONF_CC ... "
      rm -f ${LSOF_TMPC}.*
      cat > $LSOF_TMPC.c << .LSOF_END_HERE_DOC1
#include <features.h>
main() {
#if defined(__GLIBC__) && defined(__GLIBC_MINOR__)
printf("-DGLIBCV=%d\n",__GLIBC__*100+__GLIBC_MINOR__);
#elif defined(__GLIBC__)
printf("-DGLIBCV=%d00\n",__GLIBC__);
#else
printf("\n");
#endif
return(0); }
.LSOF_END_HERE_DOC1
      $LINUX_CONF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1
      if test -x ${LSOF_TMPC}.x	# {
      then
	LINUX_CLIB=`${LSOF_TMPC}.x`
	LSOF_TMP=$?
      else
	LINUX_CLIB=""
	LSOF_TMP=1
      fi	# }
      rm -f ${LSOF_TMPC}.*
      echo "done"
      if test $LSOF_TMP -ne 0	# {
      then
	echo "Cannot determine C library type; assuming it is not glibc."
	LINUX_CLIB=""
      else
	if test "X$LINUX_CLIB" = "X"	# {
	then
	  echo "The C library type is not glibc."
	else
	  echo "The C library type is glibc, version \"$LINUX_CLIB\"."
	fi	# }
      fi	# }
    fi	# }
    if test "X$LINUX_CLIB" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF $LINUX_CLIB"
    fi	# }

    # Test for IPv6 support.

    if test -r ${LSOF_INCLUDE}/netinet/ip6.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }

    # Test for <rpc/rpc.h>.

    if ! test -r ${LSOF_INCLUDE}/rpc/rpc.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNORPC_H"
    fi	# }

    # Test for SELinux support.

    LSOF_TMP1=0
    if test "X$LINUX_HASSELINUX" = "X"	# {
    then
      if test -r ${LSOF_INCLUDE}/selinux/selinux.h	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      if test "X$LINUX_HASSELINUX" = "XY" -o "X$LINUX_HASSELINUX" = "Xy" # {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test $LSOF_TMP1 -eq 1	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASSELINUX"
      LSOF_CFGL="$LSOF_CFGL -lselinux"
    fi	# }
    LSOF_DIALECT_DIR="linux"
    LSOF_CFGF="$LSOF_CFGF -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE"
    ;;

# Configure for NetBSD.

  netbsd)
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then
      
      # Validate the NetBSD version.

      case $LSOF_VSTR in	# {
      1.2*)
	LSOF_VERS="1002000"
	;;
      1.3*)
	LSOF_VERS="1003000"
	;;
      1.4*)
	LSOF_VERS="1004000"
	;;
      1.5*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="1005000"
	;;
      1.6*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="1006000"
	;;
      1*)
	LSOF_VERS="1006000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 1.6"
	;;
      2.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2000000"
	;;
      2.99.9)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2099009"
	;;
      2.99.10)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2099010"
	;;
      2.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="2099010"
	;;
      2*)
	LSOF_VERS="2000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 2.0"
	;;
      3.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="3000000"
	;;
      3.99.*)
	LSOF_TSTBIGF=" "
	LSOF_VERS="3099000"
	;;
      3*)
	LSOF_VERS="3000000"
	echo "!!!WARNING!!!  Unsupported NetBSD version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for NetBSD 3.0"
	;;
      *)
	echo "Unknown NetBSD release: $LSOF_VSTR"
	echo Assuming NetBSD 1.6
	LSOF_VERS="1006000"
	;;
      esac	# }
    fi	# }

    # Test for legal NetBSD version.

    case $LSOF_VERS in	# {
    1002000|1003000|1004000|1005000|1006000)
      ;;
    2000000|2099009|2099010)
      ;;
    3000000|3099000)
      ;;
    *)
      echo "Unknown NetBSD version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DNETBSDV=$LSOF_VERS"
    LSOF_TMP1="-DN_UNIXV=/netbsd"
    if test -r ${LSOF_INCLUDE}/util.h	# {
    then
      grep -q getbootfile ${LSOF_INCLUDE}/util.h
      if test $? -eq 0	# {
      then
	LSOF_CFGL="$LSOF_CFGL -lutil"
	LSOF_TMP1="-DHASGETBOOTFILE"
      fi	# }
    fi	# }
    LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
    if test -r ${LSOF_INCLUDE}/kvm.h	# {
    then
      grep -q kvm_getproc2 ${LSOF_INCLUDE}/kvm.h
      if test $? -eq 0	# {
      then
	  LSOF_CFGF="$LSOF_CFGF -DHASKVMGETPROC2"
      fi	# }
    fi	# }

  # Here begin the dual tests on header files that may be in $LSOF_INCLUDE
  # or $NETBSD_SYS.
  #
  # Note that $LSOF_TMP1 holds an indicator of the need for -I$NETBSD_SYS.
  # LSOF_TMP4 contains a temporary indicator of the use of $NETBSD_SYS.

    LSOF_TMP1=0
    if test "X$NETBSD_SYS" = "X"	# {
    then
      if test -d /usr/src	# {
      then
	NETBSD_SYS="/usr/src/sys"
      else
	NETBSD_SYS=$LSOF_INCLUDE
      fi	# }
    fi	# }
    LSOF_TMP2="nfs/nfsproto.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="netinet/ip6.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      LSOF_TMP2="netinet/in.h"
      if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
	LSOF_TMP4=0
      else
	if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
	then
	  LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	  LSOF_TMP4=1
	else
	  LSOF_TMP3=""
	fi	# }
      fi	# }
      if test "X$LSOF_TMP3" != "X"	# {
      then
	grep -q IPV6_INRIA_VERSION $LSOF_TMP3
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASIPv6 -DHASINRIAIPv6"
	  if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	  then
	    LSOF_TMP1=1
	  fi	# }
	fi	# }
      fi # }
    fi	# }
    LSOF_TMP2="miscfs/fdesc/fdesc.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q Fctty $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=1"
      else
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=2"
      fi	# }
      grep -q fd_link $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDLINK"
      fi	# }
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="miscfs/nullfs/null.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="miscfs/procfs"
    if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
      if test -r ${LSOF_TMP3}/procfs.h	# {
      then
	grep -q PFSroot ${LSOF_TMP3}/procfs.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPROCFS_PFSROOT"
	fi #	}
      fi	# }
    fi	# }
    LSOF_TMP2="sys/bufq.h"
    LSOF_NBSD_BUFQH=0
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASBUFQ_H"
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	if test $NETBSD_SYS != $LSOF_INCLUDE	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASBUFQ_H"
	  LSOF_NBSD_BUFQH=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="isofs/cd9660"
    if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS9660FS=1"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      LSOF_TMP2="fs/cd9660"
      if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
	LSOF_TMP4=0
      else
	if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
	then
	  LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	  LSOF_TMP4=1
	else
	  LSOF_TMP3=""
	fi	# }
      fi	# }
      if test "X$LSOF_TMP3" != "X"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS9660FS=1"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="msdosfs"
    if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS=1"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    else
      LSOF_TMP2="fs/msdosfs"
      if test -d ${LSOF_INCLUDE}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
	LSOF_TMP4=0
      else
	if test -d ${NETBSD_SYS}/$LSOF_TMP2	# {
	then
	  LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	  LSOF_TMP4=1
	else
	  LSOF_TMP3=""
	fi	# }
      fi	# }
      if test "X$LSOF_TMP3" != "X"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS=2"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="miscfs/kernfs/kernfs.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q "kt_name;" $LSOF_TMP3
      if test $? -eq 0	# {
	then
 	  LSOF_CFGF="$LSOF_CFGF -DHASKERNFS"
	  if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	  then
	    LSOF_TMP1=1
	  fi	# }
	  grep -q "*kfs_kt;" $LSOF_TMP3
	  if test $? -eq 0      # {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASKERNFS_KFS_KT"
	  fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/namei.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q nc_vpid $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="ufs/ufs/inode.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q i_ffs_size $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASI_FFS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      else
	grep -q i_ffs1_size $LSOF_TMP3
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASI_FFS1"
	  if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	  then
	    LSOF_TMP1=1
	  fi	# }
	fi	# }
      fi	# }
      grep -q i_ffs_effnlink $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASEFFNLINK=i_ffs_effnlink"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/vnode.h"
    LSOF_NBSD_PTYFS=0
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "XLSOF_TMP3" != "X"	# {
    then
      grep -q VT_EXT2FS $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
	LSOF_TMP2="ufs/ufs/inode.h"
	if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
	then
	  LSOF_TMP5="${LSOF_INCLUDE}/$LSOF_TMP2"
	  LSOF_TMP6=0
	else
	  if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
	  then
	    LSOF_TMP5="${NETBSD_SYS}/$LSOF_TMP2"
	    LSOF_TMP6=1
	  else
	    LSOF_TMP5=""
	  fi	# }
	fi	# }
	if test "X$LSOF_TMP5" != "X"	# {
	then
	  grep -q "*e2fs_din" $LSOF_TMP5
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASI_E2FS_PTR"
	    if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	    then
	      LSOF_TMP1=$LSOF_TMP6
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
      grep -q VT_LFS $LSOF_TMP3
      if test $? -eq 0   # {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASLFS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
      grep -q VT_PTYFS $LSOF_TMP3
      if test $? -eq 0   # {
      then
	LSOF_TMP2="fs/ptyfs/ptyfs.h"
	if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPTYFS"
	else
	  if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
	  then
	    if test $NETBSD_SYS != $LSOF_INCLUDE	# {
	    then
	      LSOF_CFGF="$LSOF_CFGF -DHASPTYFS"
	      LSOF_NBSD_PTYFS=1
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }
      if test "X$NETBSD_UVM" = "X"	# {
      then
	grep -q UVM $LSOF_TMP3
	if test $? -ne 0	# {
	then
	  egrep -q "v_uvm;|v_uobj;" $LSOF_TMP3
	  if test $? -eq 0	# {
	  then
	    NETBSD_UVM="Y"
	  fi	# }
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="nfs/nfsnode.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q "*n_vattr" $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNFSVATTRP"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/lockf.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q vop_advlock_args $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_ADVLOCK_ARGS"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
      grep -q lf_lwp $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_LF_LWP"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/lwp.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_LWP_H"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    LSOF_TMP2="sys/filedesc.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      grep -q "^struct cwdinfo {" $LSOF_TMP3
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASCWDINFO"
	if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
	then
	  LSOF_TMP1=1
	fi	# }
      fi	# }
    fi	# }
    LSOF_TMP2="sys/pipe.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
      LSOF_TMP4=0
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
	LSOF_TMP4=1
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_PIPEH"
      if test $LSOF_TMP1 -eq 0 -a $LSOF_TMP4 -eq 1	# {
      then
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/statvfs.h 	# {
    then
      grep -q '^struct statvfs {' ${LSOF_INCLUDE}/sys/statvfs.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASSTATVFS"
      fi	# }
    fi	# }

  # Here end the dual NetBSD tests for header files in $LSOF_INCLUDE or
  # NETBSD_SYS.
  #
  # After this LSOF_TMP1 may be reused.

    if test $LSOF_TMP1 -eq 1	# {
    then
      LSOF_DINC="-I$LSOF_INCLUDE -I$NETBSD_SYS"
    fi	# }

  # Build special header files, as required.

    rm -rf dialects/n+obsd/include
    if test "X$NETBSD_UVM" = "XY" -o "X$NETBSD_UVM" = "Xy"	# {
    then
      mkdir dialects/n+obsd/include
      touch dialects/n+obsd/include/opt_uvmhist.h
      touch dialects/n+obsd/include/opt_lockdebug.h
      LSOF_CFGF="$LSOF_CFGF -DUVM -I`pwd`/dialects/n+obsd/include"
      if test -d ${LSOF_INCLUDE}/uvm	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_UVM_INCL"
      fi	# }
    fi	# }
    LSOF_TMP2="sys/mount.h"
    if test -r ${LSOF_INCLUDE}/$LSOF_TMP2	# {
    then
      LSOF_TMP3="${LSOF_INCLUDE}/$LSOF_TMP2"
    else
      if test -r ${NETBSD_SYS}/$LSOF_TMP2	# {
      then
	LSOF_TMP3="${NETBSD_SYS}/$LSOF_TMP2"
      else
	LSOF_TMP3=""
      fi	# }
    fi	# }
    if test "X$LSOF_TMP3" != "X"	# {
    then

      # Build a local NetBSD netexport.h header file for possible use by
      # <msdosfs/msdosfsmount.h>.  Make sure CFGL contains a -I for it.

      LSOF_TMP1=${LSOF_TMPC}.edscr
      LSOF_TMP2=${LSOF_TMPC}.netcred
      LSOF_TMP3=${LSOF_TMPC}.netexport
      LSOF_TMP4=dialects/n+obsd/include/netexport.h
      if test ! -d dialects/n+obsd/include	# {
      then
	mkdir dialects/n+obsd/include
      fi	# }
      rm -f $LSOF_TMP1 $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 
      echo "/^struct netcred" > $LSOF_TMP1
      echo "1,.-1d" >> $LSOF_TMP1
      echo "/^};" >> $LSOF_TMP1
      echo "1,.w $LSOF_TMP2" >> $LSOF_TMP1
      ed ${LSOF_INCLUDE}/sys/mount.h < $LSOF_TMP1 > /dev/null 2>&1
      rm -f $LSOF_TMP1
      echo "/^struct netexport" > $LSOF_TMP1
      echo "1,.-1d" >> $LSOF_TMP1
      echo "/^};" >> $LSOF_TMP1
      echo "1,.w $LSOF_TMP3" >> $LSOF_TMP1
      ed ${LSOF_INCLUDE}/sys/mount.h < $LSOF_TMP1 > /dev/null 2>&1
      echo "/*" > $LSOF_TMP4
      echo " * netexport.h" >> $LSOF_TMP4
      echo -n " * Created by Configure: " >> $LSOF_TMP4
      echo `date` >> $LSOF_TMP4
      echo " */" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      echo "#if	!defined(NETEXPORT_H)" >> $LSOF_TMP4
      echo "#define	NETEXPORT_H" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      echo "#include <net/radix.h>" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      if test -r $LSOF_TMP2	# {
      then
	cat $LSOF_TMP2 >> $LSOF_TMP4
	echo "" >> $LSOF_TMP4
      fi	# }
      if test -r $LSOF_TMP3	# {
      then
	cat $LSOF_TMP3 >> $LSOF_TMP4
      fi	# }
      echo "#endif	/* !defined(NETEXPORT_H) */" >> $LSOF_TMP4
      rm -f $LSOF_TMP1 $LSOF_TMP2 $LSOF_TMP3
      echo $LSOF_CFGF | grep /dialects/n+obsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/n+obsd/include"
      fi	# }
    fi	# }
    if test $LSOF_NBSD_BUFQH -eq 1	# {
    then

    # Make a local copy of $NETBSD_SYS/sys/bufq.h.

      if test ! -d dialects/n+obsd/include	# {
      then
	mkdir dialects/n+obsd/include
      fi	# }
      if test ! -d dialects/n+obsd/include/sys	# {
      then
	mkdir dialects/n+obsd/include/sys
      fi	# }
      cp $NETBSD_SYS/sys/bufq.h dialects/n+obsd/include/sys
      echo $LSOF_CFGF | grep /dialects/n+obsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/n+obsd/include"
      fi	# }
    fi	# }
    if test $LSOF_NBSD_PTYFS -eq 1	# {
    then

    # Make a local copy of $NETBSD_SYS/sys/fs/ptyfs/.

      if test ! -d dialects/n+obsd/include	# {
      then
	mkdir dialects/n+obsd/include
      fi	# }
      if test ! -d dialects/n+obsd/include/fs	# {
      then
	mkdir dialects/n+obsd/include/fs
      fi	# }
      rm -rf dialects/n+obsd/include/fs/ptyfs
      mkdir dialects/n+obsd/include/fs/ptyfs
      cp $NETBSD_SYS/fs/ptyfs/*.h dialects/n+obsd/include/fs/ptyfs
      echo $LSOF_CFGF | grep /dialects/n+obsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/n+obsd/include"
      fi	# }
    fi	# }
    LSOF_CFGL="$LSOF_CFGL -lkvm"
    LSOF_DIALECT_DIR=n+obsd
    ;;

# Configure for NeXTSTEP or OPENSTEP.

  nextstep|next|ns|nxt|openstep|os)
    LSOF_TGT="ns"
    LSOF_TSTXO="../lib/snpf.o"
    if test "X$LSOF_AR" = "X"	# {
    then
      LSOF_AR="rm -f \${LIB}; ar cr"
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`hostinfo | sed -n 's/.*NeXT Mach \([0-9\.]*\).*/\1/p'`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the NeXSTEP version isn't predefined, determine it.

      LSOF_VERS=`echo $LSOF_VSTR | sed -n 's/\([0-9]*\)\.\([0-9]*\)/\1\2/p'`
    fi	# }
    if test "X$LSOF_CC" = "X"	# {
    then
      if test -x /usr/local/bin/gcc	# {
      then
	LSOF_CC=/usr/local/bin/gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
      else
	LSOF_CC=cc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
      fi	# }
    fi	# }
    echo $LSOF_CC | grep gcc > /dev/null
    if test $? -eq 0	# {
    then
      LSOF_CFGL="$LSOF_CFGL -w"
      LSOF_DEBUG="-pedantic -O"
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DSTEPV=$LSOF_VERS"
    LSOF_DIALECT_DIR=n+os

    # Test for AFS.

    if test -r ${AFS_VICE}/etc/ThisCell	# {
    then
      if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
      then
	if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	then
	  LSOF_AFS="yes"
	fi	# }
      else
	if test ! -x ./AFSConfig	# {
	then
	  echo "Can't find or execute the AFSConfig script"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	./AFSConfig
	if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	then
	    LSOF_AFS="yes"
	fi	# }
      fi	# }
      if test "X$LSOF_AFS" = "Xyes"	# {
      then
	LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
      fi	# }
    fi	# }
    ;;

# Configure for OpenBSD.  (OpenBSD uses NetBSD dialect sources and version
# numbering.

  openbsd)
    if test "X$LSOF_CC" = "X"	# {
    then
      LSOF_CC=cc
      LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the OpenBSD version isn't pre-defined, determine it.

      case $LSOF_VSTR in	# {
      1*)
	LSOF_VERS=1020
	echo "!!!WARNING!!!  Unsupported OpenBSD 1.x version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for OpenBSD 1.2"
	;;
      2.5*)
	LSOF_VERS=2050
	;;
      2.6*)
	LSOF_VERS=2060
	;;
      2.7*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2070
	;;
      2.8*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2080
	;;
      2.9*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2090
	;;
      2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=2090
	echo "!!!WARNING!!!  Unsupported OpenBSD 2.x version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for OpenBSD 2.9"
	;;
      3.0*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3000
	;;
      3.1*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3010
	;;
      3.2*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3020
	;;
      3.3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3030
	;;
      3.4*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3040
	;;
      3.5*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3050
	;;
      3.6*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3060
	;;
      3.7*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3070
	;;
      3.8*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3080
	;;
      3.9*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3090
	;;
      3*)
	LSOF_TSTBIGF=" "
	LSOF_VERS=3090
	echo "!!!WARNING!!!  Unsupported OpenBSD 3.x version: $LSOF_VSTR"
	echo "!!!WARNING!!!  Configuring for OpenBSD 3.9"
	;;
      *)
	echo "Unknown OpenBSD release: $LSOF_VSTR"
	echo Assuming OpenBSD 3.9
	LSOF_VERS=3090
	;;
      esac	# }
    fi	# }

    # Test for legal OpenBSD version.

    case $LSOF_VERS in	# {
    1020|2050|2060|2070|2080|2090|3000|3010|3020|3030|3040|3050|3060|3070|3080|3090)
      ;;
    *)
      echo "Unknown OpenBSD version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DOPENBSDV=$LSOF_VERS"
    if test -r /dev/ksyms	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=/dev/ksyms"
    else
      LSOF_CFGF="$LSOF_CFGF -DN_UNIXV=/bsd"
    fi
    if test -r ${LSOF_INCLUDE}/nfs/nfsproto.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNFSPROTO"
    fi	# }
    if test -r ${LSOF_INCLUDE}/netinet6/in6.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
    fi	# }
    LSOF_TMP1=0
    if test "X$OPENBSD_SYS" = "X"	# {
    then
      OPENBSD_SYS="/sys"
    fi	# }
    if test -r ${OPENBSD_SYS}/miscfs/fdesc/fdesc.h	# {
    then
      grep -q Fctty ${OPENBSD_SYS}/miscfs/fdesc/fdesc.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=1"
      else
	LSOF_CFGF="$LSOF_CFGF -DHASFDESCFS=2"
      fi	# }
      grep -q fd_link ${OPENBSD_SYS}/miscfs/fdesc/fdesc.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASFDLINK"
      fi	# }
      LSOF_TMP1=1
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
    then
      grep -q VT_LFS ${LSOF_INCLUDE}/sys/vnode.h
      if test $? -eq 0   # {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASLFS"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/miscfs/nullfs/null.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
    else
      if test -r ${OPENBSD_SYS}/miscfs/nullfs/null.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNULLFS"
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test -d ${OPENBSD_SYS}/miscfs/procfs	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASPROCFS"
      LSOF_TMP1=1
    fi	# }
    if test -d ${OPENBSD_SYS}/isofs/cd9660	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS9660FS=1"
      LSOF_TMP1=1
    else
      if test -d ${OPENBSD_SYS}/fs/cd9660	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS9660FS=2"
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test -d ${OPENBSD_SYS}/msdosfs	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS=1"
      LSOF_TMP1=1
    else
      if test -d ${OPENBSD_SYS}/fs/msdosfs	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASMSDOSFS=2"
	LSOF_TMP1=1
      fi	# }
    fi	# }
    if test -r ${OPENBSD_SYS}/miscfs/kernfs/kernfs.h	# {
    then
      grep -q "kt_name;" ${OPENBSD_SYS}/miscfs/kernfs/kernfs.h
      if test $? -eq 0	# {
	then
 	  LSOF_CFGF="$LSOF_CFGF -DHASKERNFS"
	  LSOF_TMP1=1
      fi	# }
    fi	# }
    if test $LSOF_TMP1 -eq 1 -a "X$LSOF_INCLUDE" != "X$OPENBSD_SYS"	# {
    then
      LSOF_DINC="-I$LSOF_INCLUDE -I$OPENBSD_SYS"
    fi	# }
    grep -q VT_EXT2FS ${LSOF_INCLUDE}/sys/vnode.h
    if test $? -eq 0	# {
    then
      LSOF_TMP1=1
      if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h	# {
      then
	grep -q "*e2fs_din" ${LSOF_INCLUDE}/ufs/ufs/inode.h
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASI_E2FS_PTR"
	fi	# }
	grep -q "^#define[ 	]i_e2din" ${LSOF_INCLUDE}/ufs/ufs/inode.h
	if test $? -eq 0	# {
	then
	  LSOF_TMP1=2
	fi	# }
      fi	# }
      LSOF_CFGF="$LSOF_CFGF -DHASEXT2FS=$LSOF_TMP1"
    fi	# }
    if test -r ${LSOF_INCLUDE}/ufs/ufs/inode.h	# {
    then
      grep -q i_effnlink ${LSOF_INCLUDE}/ufs/ufs/inode.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASEFFNLINK=i_effnlink"
      fi	# }
      grep -q dinode_u ${LSOF_INCLUDE}/ufs/ufs/inode.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_DINODE_U"
      fi	# }
      grep -q i_ffs1_size ${LSOF_INCLUDE}/ufs/ufs/inode.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASI_FFS1"
      fi	# }
      grep -q UM_UFS ${LSOF_INCLUDE}/ufs/ufs/inode.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_UM_UFS"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/namei.h
    then
      grep -q nc_vpid ${LSOF_INCLUDE}/sys/namei.h
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASNCVPID"
      fi	# }
    fi	# }
    if test "X$OPENBSD_UVM" = "X"	# {
    then
      if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
      then
	grep -q UVM ${LSOF_INCLUDE}/sys/vnode.h
	if test $? -ne 0	# {
	then
	  egrep -q "v_uvm;|v_uobj;" ${LSOF_INCLUDE}/sys/vnode.h
	  if test $? -eq 0	# {
	  then
	    OPENBSD_UVM="Y"
	  fi	# }
	fi	# }
      fi	# }
    fi	# }
    if test "X$OPENBSD_UVM" = "XY" -o "X$OPENBSD_UVM" = "Xy"	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DUVM"
      if test -d ${LSOF_INCLUDE}/uvm	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_UVM_INCL"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/mount.h -a $LSOF_VERS -lt 3030	# {
    then

      # Build a local OpenBSD netexport.h header file for possible use by
      # <msdosfs/msdosfsmount.h>.  Make sure CFGL contains a -I for it.

      LSOF_TMP1=${LSOF_TMPC}.edscr
      LSOF_TMP2=${LSOF_TMPC}.netcred
      LSOF_TMP3=${LSOF_TMPC}.netexport
      LSOF_TMP4=dialects/n+obsd/include/netexport.h
      if test ! -d dialects/n+obsd/include	# {
      then
	mkdir dialects/n+obsd/include
      fi	# }
      rm -f $LSOF_TMP1 $LSOF_TMP2 $LSOF_TMP3 $LSOF_TMP4 
      echo "/^struct netcred" > $LSOF_TMP1
      echo "1,.-1d" >> $LSOF_TMP1
      echo "/^};" >> $LSOF_TMP1
      echo "1,.w $LSOF_TMP2" >> $LSOF_TMP1
      ed ${LSOF_INCLUDE}/sys/mount.h < $LSOF_TMP1 > /dev/null 2>&1
      rm -f $LSOF_TMP1
      echo "/^struct netexport" > $LSOF_TMP1
      echo "1,.-1d" >> $LSOF_TMP1
      echo "/^};" >> $LSOF_TMP1
      echo "1,.w $LSOF_TMP3" >> $LSOF_TMP1
      ed ${LSOF_INCLUDE}/sys/mount.h < $LSOF_TMP1 > /dev/null 2>&1
      echo "/*" > $LSOF_TMP4
      echo " * netexport.h" >> $LSOF_TMP4
      echo -n " * Created by Configure: " >> $LSOF_TMP4
      echo `date` >> $LSOF_TMP4
      echo " */" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      echo "#if	!defined(NETEXPORT_H)" >> $LSOF_TMP4
      echo "#define	NETEXPORT_H" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      echo "#include <net/radix.h>" >> $LSOF_TMP4
      echo "" >> $LSOF_TMP4
      if test -r $LSOF_TMP2	# {
      then
	cat $LSOF_TMP2 >> $LSOF_TMP4
	echo "" >> $LSOF_TMP4
      fi	# }
      if test -r $LSOF_TMP3	# {
      then
	cat $LSOF_TMP3 >> $LSOF_TMP4
      fi	# }
      echo "#endif	/* !defined(NETEXPORT_H) */" >> $LSOF_TMP4
      rm -f $LSOF_TMP1 $LSOF_TMP2 $LSOF_TMP3
      echo $LSOF_CFGF | grep /dialects/n+obsd/include > /dev/null 2>&1
      if test $? -ne 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/n+obsd/include"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/lockf.h	# {
    then
      grep vop_advlock_args ${LSOF_INCLUDE}/sys/lockf.h > /dev/null
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_ADVLOCK_ARGS"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/pipe.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_SYS_PIPEH"
    fi	# }
    LSOF_CFGL="$LSOF_CFGL -lkvm"
    LSOF_DIALECT_DIR=n+obsd
    ;;

# Configure for SCO OpenServer.

  osr|osrgcc|sco|scogcc)
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$OSR_CFGF" != "X"	# {
    then

    # Adopt LSOF_CFGF from OSR_CFGF in environment.

      LSOF_CFGF=$OSR_CFGF
    fi	# }
    if test "X$OSR_CFGL" != "X"	# {
    then

    # Adopt LSOF_CFGL from OSR_CFGL in environment.

      LSOF_CFGL=$OSR_CFGL
    fi	# }

  # Evaluate compiler specification.

    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xosr" -o "X$LSOF_TGT" = "Xsco"	# {
      then
	LSOF_CC=cc
	LSOF_TMP1=1
      else
	LSOF_CC=gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
	LSOF_TMP1=2
      fi	# }
    else
	LSOF_TMP1=0
    fi	# }
    LSOF_TGT="osr"

  # Determine version.

    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR="`LANG=C_C.C /bin/uname -X 2>/dev/null | grep Release | sed 's/Release = \(.*\)/\1/'`"
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the SCO OpenServer release version isn't predefined, determine it.

      case $LSOF_VSTR in	# {
      3.2v2.0)
	LSOF_VERS="20"
	;;
      3.2v2.1)
	LSOF_VERS="21"
	;;
      3.2v4.0)
	LSOF_VERS="40"
	;;
      3.2v4.1)
	LSOF_VERS="41"
	;;
      3.2v4.2)
	LSOF_VERS="42"
	;;
      3.2v5.*)
	LSOF_TSTLFLG="-lsocket"
	LSOF_VERS="`echo $LSOF_VSTR | sed 's/3\.2v//; s/\.//g'`"
	;;
      *)
	echo Unknown SCO OpenServer release: $LSOF_VSTR
	echo Assuming 3.2.0 or 3.2.1
	LSOF_VERS="0"
	;;
      esac	# }
    fi	# }

    # Do SCO OpenServer specific stuff.

    case $LSOF_VERS in	# {
    0)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      LSOF_MKC="cp"
      ;;
    20)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      LSOF_MKC="cp"
      ;;
    21)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      LSOF_MKC="cp"
      ;;
    40)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      ;;
    41)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      ;;
    42)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -nointl"
	LSOF_DEBUG="-Ox"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lrpc -lsocket -lc_s"
      ;;
    5*)
      if test $LSOF_TMP1 -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -belf"
	LSOF_DEBUG="-O3 -Kspace"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lsocket"
      ;;
    *)
      echo "Unsupported SCO OpenServer release: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -DOSRV=$LSOF_VERS"
    if test "X$OSR_STATLSTAT" = "X"	# {
    then
      echo "Testing libc.a for statlstat"
      /bin/nm /lib/libc.a | grep statlstat > /dev/null 2>&1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT"
      fi	# }
    else
      if test "X$OSR_STATLSTAT" = "XY" -o "X$OSR_STATLSTAT" = "Xy"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_STATLSTAT"
      fi	# }
    fi	# }
    if test -r ${LSOF_INCLUDE}/sys/fs/nfs/rnode.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHAS_NFS"
    fi	# }
    if test ! -r ${LSOF_INCLUDE}/netdb.h	# {
    then
      LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/osr/include"
    fi	# }
    LSOF_DIALECT_DIR=osr
    ;;

# Configure for Sun Solaris, SunPro C and gcc.

  solaris|solariscc)
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$LSOF_CC" = "X"	# {
    then
      if test "X$LSOF_TGT" = "Xsolariscc"	# {
      then
	if test "X$SOLARIS_CCDIR" = "X"	# {
	then
	  SOLARIS_CCDIR="/opt/SUNWspro/bin"
	fi	# }
	if test -x ${SOLARIS_CCDIR}/cc	# {
	then
	  LSOF_CC=${SOLARIS_CCDIR}/cc
	else
	  if test -x /opt/SunStudioExpress/bin/cc	# {
	  then
	    LSOF_CC=/opt/SunStudioExpress/bin/cc
	  else
	    echo "WARNING: no cc in ${SOLARIS_CCDIR}; using cc without path."
	    LSOF_CC=cc
	  fi	# }
	fi	# }
	LSOF_CCV=`$LSOF_CC -V 2>&1 | sed -n 's/^cc: \(.*\)/\1/p'`
      else
	LSOF_CC=gcc
	LSOF_CCV=`$LSOF_CC -v 2>&1 | sed -n 's/.*version \(.*\)/\1/p'`
      fi	# }
    fi	# }
    LSOF_TGT="solaris"
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -r`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the Solaris version isn't predefined, determine it.

      case $LSOF_VSTR in	# {
      5.[0-2])
	LSOF_VERS="20300"
	;;
      5.3)
	LSOF_VERS="20300"
	;;
      5.4)
	LSOF_VERS="20400"
	;;
      5.5)
	LSOF_VERS="20500"
	;;
      5.5.1)
	LSOF_VERS="20501"
	;;
      5.6*)
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="20600"
	;;
      5.7*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="70000"
	;;
      5.8*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="80000"
	;;
      5.9*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="90000"
	;;
      5.10*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="100000"
	;;
      5.11*)
	LSOF_TSTBIGF=" "
	LSOF_TSTLFLG="-lsocket -lnsl"
	LSOF_VERS="110000"
	;;
      *)
	echo Unknown Solaris version: $LSOF_VSTR
	rm -f $LSOF_HLP
	exit 1
      esac	# }
    fi	# }

    # Clear LSOF_UNSUP message for selected Solaris versions.

    case $LSOF_VERS in	# {
    90000|100000|110000)
      LSOF_UNSUP=""
      ;;
    esac	# }

    # Do Solaris version-specific stuff.

    case $LSOF_VERS in	# {
    20300)

      # Solaris patch 101318-32 creates a longer kernel tcp_s structure,
      # and 101318-45 changes the way the vnode's v_filocks member is
      # handled.  The following code creates a symbol definition for
      # patch 101318 whose value is the patch level.  No symbol is defined
      # if the patch level is not greater than zero.

      if test "X$SOLARIS_23P101318" = "X"	# {
      then
	LSOF_PL=`grep -h SUNW_PATCHID=101318 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1`
	if test "X$LSOF_PL" = "X"	# {
	then
	  LSOF_PL=0
	fi	# }
      else
	LSOF_PL=$SOLARIS_23P101318
      fi	# }
      if test $LSOF_PL -gt 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DP101318=$LSOF_PL"
      fi	# }
      ;;
    20400)
      if test "X$SOLARIS_24P101945" = "X"	# {
      then
	LSOF_PL=`grep -h SUNW_PATCHID=101945 /var/sadm/pkg/SUNWcar*/pkginfo | sed 's/.*-//' | sort -u | tail -1`
	if test "X$LSOF_PL" = "X"	# {
	then
	  LSOF_PL=0
	fi	# }
      else
	LSOF_PL=$SOLARIS_24P101945
      fi	# }
      if test $LSOF_PL -ge 32	# {
      then
	if test "X$SOLARIS_24P102303" = "X"	# {
	then
	  LSOF_PL=`grep -h SUNW_PATCHID=102303 /var/sadm/pkg/SUNWhea*/pkginfo | sed 's/.*-//' | sort -u | tail -1`
	  if test "X$LSOF_PL" = "X"	# {
	  then
	    LSOF_PL=0
	  fi	# }
	else
	  LSOF_PL=$SOLARIS_24P102303
	fi	# }
	if test $LSOF_PL -ge 2	# {
	then
	  echo "WARNING: your Solaris 2.4 system appears to have patches 101945-32 and 102303-2"
	  echo "         installed.  This probably means the NUM_*_VECTORS definitions in"
	  echo "         <sys/auxv.h> don't match the ones used to build your kernel.  Consult"
	  echo "         the Sun Problems section of the 00FAQ file of the lsof distribution"
	  echo "         for more information on how to work around the problem."
	fi	# }
      fi	# }
      ;;
    20500|20501)
      ;;
    20600|70000|80000|90000|100000|110000)
      if test "X$SOLARIS_26PR_GWINDOWS" = "X"	# {
      then
	rm -f ${LSOF_TMPC}.*
	echo "#define _KMEMUSER" > ${LSOF_TMPC}.c
	echo "#include <sys/proc/prdata.h>" >> ${LSOF_TMPC}.c
	echo "main(){" >> ${LSOF_TMPC}.c
	echo "enum prnodetype p=PR_GWINDOWS;}" >> ${LSOF_TMPC}.c
	echo "Testing prdata.h for PR_GWINDOWS, using $LSOF_CC"
	echo $LSOF_CC | grep gcc > /dev/null
	if test $? -eq 0	# {
	then
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x  > /dev/null 2>&1
	else
	  $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x  > /dev/null 2>&1
	fi	# }
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS"
	fi	# }
      else
	if test "X$SOLARIS_26PR_GWINDOWS" = "XY" -o "X$SOLARIS_26PR_GWINDOWS" = "Xy"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_GWINDOWS"
	fi	# }
      fi	# }
      if test "X$SOLARIS_26PR_LDT" = "X"	# {
      then
	rm -f ${LSOF_TMPC}.*
	echo "#define _KMEMUSER" > ${LSOF_TMPC}.c
	echo "#include <sys/proc/prdata.h>" >> ${LSOF_TMPC}.c
	echo "main(){" >> ${LSOF_TMPC}.c
	echo "enum prnodetype p=PR_LDT;}" >> ${LSOF_TMPC}.c
	echo "Testing prdata.h for PR_LDT, using $LSOF_CC"
	echo $LSOF_CC | grep gcc > /dev/null
	if test $? -eq 0	# {
	then
	  $LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
	else
	  $LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1
	fi	# }
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT"
	fi	# }
	rm -f ${LSOF_TMPC}.*
      else
	if test "X$SOLARIS_26PR_LDT" = "XY" -o "X$SOLARIS_26PR_LDT" = "Xy"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASPR_LDT"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 70000	# {
      then

      # Do tests for Solaris 7 and above.

	if test "X$SOLARIS_KERNBITS" = "X"	# {
	then
	  SOLARIS_KERNBITS=`/bin/isainfo -kv`
	fi	# }
	if test "X$SOLARIS_INSTR" = "X"	# {
	then
	  SOLARIS_INSTR=`/bin/isainfo -k`
	fi	#}
	echo $SOLARIS_KERNBITS | grep 64 > /dev/null
	if test $? -eq 0	# {
	then
	  echo $LSOF_CC | grep gcc > /dev/null
	  if test $? -eq 0	# {
	  then

	# Test gcc for 64 bit support.

	    echo "Testing $LSOF_CC for 64 bit support"
	    rm -f ${LSOF_TMPC}.*
	    echo "main(){}" > ${LSOF_TMPC}.c
	    LSOF_TMP1=""

	# First try gcc's -m64 option -- it's the most current possibility.

	    $LSOF_CC ${LSOF_TMPC}.c -m64 -o ${LSOF_TMPC}.x > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      /bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null 
	      if test $? -eq 0	# {
	      then
		LSOF_TMP1="-m64"
	      fi	# }
	    fi	# }
	    rm -f ${LSOF_TMPC}.*
	    if test "X$LSOF_TMP1" = "X"	# {
	    then

	    # Try using the older -mcpu=v9 option with gcc instead of -m64.

	      echo "main(){}" > ${LSOF_TMPC}.c
	      $LSOF_CC ${LSOF_TMPC}.c -mcpu=v9 -o ${LSOF_TMPC}.x > /dev/null 2>&1
	      if test $? -eq 0	# {
	      then
		/bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null 
		if test $? -eq 0	# {
		then
		  LSOF_TMP1="-mcpu=v9"
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.*
	    fi	# }
	    if test "X$LSOF_TMP1" = "X"	# {
	    then
	      echo ""
	      echo "!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!"
	      echo "!                                                       !"
	      echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT  !"
	      echo "! THIS GCC DOESN'T SUPPORT THE BUILDING OF 64 BIT       !"
	      echo "! SOLARIS EXECUTABLES.  LSOF WILL BE CONFIGURED FOR A   !"
	      echo "! 32 BIT KERNEL.                                        !"
	      echo "!                                                       !"
	      echo "!!!WARNING!!!=========!!!WARNING!!!=========!!!WARNING!!!"
	      echo ""
	    else
	      echo ""
	      echo "*********************************"
	      echo "* Configuring for 64 bit kernel *"
	      echo "*********************************"
	      echo ""
	      LSOF_CFGF="$LSOF_CFGF $LSOF_TMP1"
	      LSOF_CINFO="64 bit kernel"
	      LSOF_TSTK64=1
	    fi	# }
	  else

	  # Test Sun compiler for 64 bit support.

	    case $SOLARIS_INSTR in	# {
	    amd64*)
	      LSOF_TMP1="amd64"
	      LSOF_TMP2="amd64"
	      ;;
	    sparc*)
	      LSOF_TMP1="v9"
	      LSOF_TMP2="sparcv9"
	      ;;
	    *)
	      LSOF_TMP1=""
	      ;;
	    esac	# }
	    if test "X$LSOF_TMP1" != "X"	# {
	    then
	      echo "Testing $LSOF_CC for 64 bit $LSOF_TMP2 support"
	      rm -f ${LSOF_TMPC}.*
	      LSOF_TMP3="-xarch=$LSOF_TMP1"
	      echo "main(){}" > ${LSOF_TMPC}.c
	      LSOF_TMP4=`$LSOF_CC ${LSOF_TMPC}.c $LSOF_TMP3 -o ${LSOF_TMPC}.x 2>&1`
	      if test $? -eq 0	# {
	      then
		/bin/file ${LSOF_TMPC}.x | /bin/grep 64 > /dev/null 
		if test $? -ne 0	# {
		then
		  LSOF_TMP3=""
		else
		  echo "X$LSOF_TMP4" | grep "use -m64" > /dev/null 2>&1
		  if test $? -eq 0	# {
		  then
		    LSOF_TMP3=-m64
		  fi	# }
		fi	# }
	      fi	# }
	      rm -f ${LSOF_TMPC}.*
	    else
	      LSOF_TMP3=""
	    fi	# }
	    if test "X$LSOF_TMP3" != "X"	# {
	    then
	      echo ""
	      echo "*********************************"
	      echo "* Configuring for 64 bit kernel *"
	      echo "*********************************"
	      echo ""
	      LSOF_CFGF="$LSOF_CFGF $LSOF_TMP3"
	      LSOF_CINFO="64 bit kernel"
	      LSOF_TSTK64=1
	    else
	      echo ""
	      echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!"
	      echo "!"
	      echo "! LSOF NEEDS TO BE CONFIGURED FOR A 64 BIT KERNEL, BUT"
	      echo "! THE VERSION OF SUN C AVAILABLE DOESN'T SUPPORT THE"
	      echo "! \"$LSOF_TMP2\" INSTRUCTION SET."
	      echo "!"
	      echo "! LSOF WILL BE CONFIGURED FOR A 32 BIT KERNEL."
	      echo "!"
	      echo "!!!WARNING!!!==========!!!WARNING!!!==========!!!WARNING!!!"
	      echo ""
	    fi	# }
	  fi	# }
	else
	  echo ""
	  echo "*********************************"
	  echo "* Configuring for 32 bit kernel *"
	  echo "*********************************"
	  echo ""
	  LSOF_CINFO="32 bit kernel"
	fi	# }
      fi	# }

      # Do tests specific to Solaris 8 and above.

      if test $LSOF_VERS -ge 80000	# {
      then
	if test -r ${LSOF_INCLUDE}/netinet/ip6.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
	fi	# }
      fi	# }

      # Do tests specific to Solaris 9 and above.

      if test $LSOF_VERS -ge 90000	# {
      then
	if test -r ${LSOF_INCLUDE}/sys/socketvar.h	# {
	then
	  grep soua_vp ${LSOF_INCLUDE}/sys/socketvar.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASSOUXSOUA"
	  fi	# }
	fi	# }
	if test $LSOF_VERS -lt 110000	# {
	then

	# Do tests specific to Solaris 9 and 10.

	  if test -r ${LSOF_INCLUDE}/sys/lgrp_user.h      # {
	  then
	    if test -r ${LSOF_INCLUDE}/sys/lgrp.h      # {
	    then
	      grep lgrp_root ${LSOF_INCLUDE}/sys/lgrp_user.h > /dev/null 2>&1
	      if test $? -eq 0	# {
	      then
		grep lgrp_root ${LSOF_INCLUDE}/sys/lgrp.h > /dev/null 2>&1
		if test $? -eq 0
		then
		  LSOF_CFGF="$LSOF_CFGF -DHAS_LGRP_ROOT_CONFLICT"
		fi	# }
	      fi	# }
	    fi	# }
	  fi	# }
	fi	# }
      fi	# }

      # Do tests specific to Solaris 10 and above.

      if test $LSOF_VERS -eq 100000	# {
      then
	if test -r ${LSOF_INCLUDE}/sys/socket_proto.h	# {
	then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_SOCKET_PROTO_H"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 100000	# {
      then
	if test -r ${LSOF_INCLUDE}/inet/ipclassifier.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_IPCLASSIFIER_H"
	  grep conn_ixa ${LSOF_INCLUDE}/inet/ipclassifier.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_CONN_NEW"
	  fi	#}
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/cred_impl.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_CRED_IMPL_H"

	  # DEBUG -- Begin temporary hack for Solaris 10, build s10_44.

	  grep "c2/audit.h" ${LSOF_INCLUDE}/sys/cred_impl.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    rm -rf `pwd`/dialects/sun/solaris10
	    mkdir `pwd`/dialects/sun/solaris10
	    mkdir `pwd`/dialects/sun/solaris10/c2
	    touch `pwd`/dialects/sun/solaris10/c2/audit.h
	    LSOF_CFGF="$LSOF_CFGF -I`pwd`/dialects/sun/solaris10"
	  fi	# }

	  # DEBUG -- End temporary hack for Solaris 10, build s10_44.

	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/vnode.h	# {
	then
	  grep v_path ${LSOF_INCLUDE}/sys/vnode.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_V_PATH"
	    LSOF_TSTVPATH=1
	  fi	# }
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/pc_fs.h	# {
	then
	  grep pc_direntpersec ${LSOF_INCLUDE}/sys/fs/pc_fs.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_PC_DIRENTPERSEC"
	  fi	# }
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/zone.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASZONES"
      fi	# }

      # Check for Solaris 10 or higher CTF library and things that depend
      # on it.

      if test -r ${LSOF_INCLUDE}/libctf.h	# {
      then
	LSOF_CTFH=1
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/fs/zfs.h	# {
      then
	if test $LSOF_CTFH -eq 1	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_ZFS"
	  LSOF_CTFL=1
	else
	  echo "WARNING: ZFS support not enabled; libctf.h missing."
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 110000	# {
      then

      # Do things specific to Solaris 11 and above.

	if test $LSOF_CTFH -eq 1	# {
	then
	  LSOF_CTFL=1
	else
	  echo "WARNING: socket support not enabled; libctf.h missing."
	fi	# }
	rm -rf ./solaris11
	mkdir ./solaris11
	mkdir ./solaris11/sys
	touch ./solaris11/sys/extdirent.h
	echo "./solaris11/sys/extdirent.h created"
	LSOF_CFGF="$LSOF_CFGF -I`pwd`/solaris11"
	if test -r ${LSOF_INCLUDE}/sys/mutex.h	# {
	then

	# Check <sys/mutex.h> 'for pad_mutex_t;'.

	  grep 'pad_mutex_t;' ${LSOF_INCLUDE}/sys/mutex.h > /dev/null 2>&1
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_PAD_MUTEX"
	  fi	# }
	fi	# )
      fi	# }

      # If -lctf was added to LSOF_CFGL, define HAS_LIBCTF.

      if test $LSOF_CTFL -eq 1	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_LIBCTF"
	LSOF_CFGL="$LSOF_CFGL -lctf"
      fi	# }
      ;;
    *)
      echo "Unsupported Solaris version: $LSOF_VERS"
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    LSOF_CFGF="$LSOF_CFGF -Dsolaris=$LSOF_VERS"

    # Test for <sys/fs/cachefs_fs.h>.

    if test -r ${LSOF_INCLUDE}/sys/fs/cachefs_fs.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASCACHEFS"
    fi	# }

    # Test for <utmpx.h>

    if test -r ${LSOF_INCLUDE}/utmpx.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASUTMPX"
    fi	# }

    # Test for VSOCK.

    if test "X$SOLARIS_VSOCK" = "X"	# {
    then
      rm -f ${LSOF_TMPC}.*
      echo "#include <sys/vnode.h>" > ${LSOF_TMPC}.c
      echo "main(){" >> ${LSOF_TMPC}.c
      echo "enum vtype p=VSOCK;}" >> ${LSOF_TMPC}.c
      echo "Testing vnode.h for VSOCK, using $LSOF_CC"
      echo $LSOF_CC | grep gcc > /dev/null
      if test $? -eq 0	# {
      then
	$LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
      else
	$LSOF_CC ${LSOF_TMPC}.c -I$LSOF_INCLUDE -o ${LSOF_TMPC}.x > /dev/null 2>&1
      fi	# }
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK"
      fi	# }
      rm -f ${LSOF_TMPC}.*
    else
      if test "X$SOLARIS_VSOCK" = "XY" -o "X$SOLARIS_VSOCK" = "Xy"	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHAS_VSOCK"
      fi	# }
    fi	# }

    # Test for AFS.

    if test -r ${AFS_VICE}/etc/ThisCell	# {
    then
      if test "X$LSOF_SCRIPT_CALL" = "Xno"	# {
      then
	if test -r ./AFSHeaders -a -r ./AFSVersion	# {
	then
	  LSOF_AFS="yes"
	fi	# }
      else
	if test ! -x ./AFSConfig	# {
	then
	  echo "Can't find or execute the AFSConfig script"
	  rm -f $LSOF_HLP
	  exit 1
	fi	# }
	./AFSConfig
	if test $? -eq 0 -a -r ./AFSHeaders -a -r ./AFSVersion	# {
	then
	    LSOF_AFS="yes"
	fi	# }
      fi	# }
      if test "X$LSOF_AFS" = "Xyes"	# {
      then
	if test "X$SUN_AFSAPATHDEF" = "X"	# {
	then
	  ls /usr/vice/etc/modload/libafs > /dev/null 2>&1
	  if test $? -ne 0	# {
	  then
	    LSOF_TMP1=`ls /usr/vice/etc/modload/libafs* 2>/dev/null | wc -l`
	    if test $LSOF_TMP1 -ne 0	# {
	    then
	      SUN_AFSAPATHDEF=`ls -t /usr/vice/etc/modload/libafs* | head -1`
	    fi	# }
	  fi	# }
	fi	# }
	if test "X$SUN_AFSAPATHDEF" != "X"	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DAFSAPATHDEF=\\\"$SUN_AFSAPATHDEF\\\""
	fi	# }
	LSOF_AFSV=`cat ./AFSVersion | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1 \2/' | awk '{printf "%d%02d\n",\$1,\$2}'`
	LSOF_CFGF="$LSOF_CFGF -DHAS_AFS=$LSOF_AFSV"
	LSOF_DINC="$LSOF_DINC -I`cat ./AFSHeaders`"
      fi	# }
    fi	# }

    # Test for VxFS.
    #
    # If the location of the VxFS header files hasn't been defined in the
    # environment, establish their likely locations.

    LSOF_TMP2=$SOLARIS_VXFSINCL
    if test -d /opt/VRTS/include	# {
    then
      LSOF_TMP2="$LSOF_TMP2 /opt/VRTS/include"
    fi	# }
    if test -d /opt/VRTSvxfs/include	# {
    then
      LSOF_TMP2="$LSOF_TMP2 /opt/VRTSvxfs/include"
    fi	# }
    LSOF_TMP1=0
    for i in $LSOF_TMP2	# {
    do
      if test -r ${i}/vxfsutil.h	# {
      then
	LSOF_TMP1=1
	SOLARIS_VXFSINCL=$i
	break
      fi	# }
    done	# }
    if test $LSOF_TMP1 -eq 1	# {
    then

    # The VxFS header files are for VxFS version 3.4 or above.  Enable VxFS
    # for those versions.

      LSOF_CFGF="$LSOF_CFGF -DHASVXFS -DHASVXFSUTIL -I$SOLARIS_VXFSINCL"

    # Determine which libvxfsutil.a is required -- 32 or 64 bit.

      LSOF_TMP2=""			# assume 32 bit
      echo "X$LSOF_CINFO" | grep "^X64" > /dev/null 2>&1
      if test $? -eq 0-a "X$SOLARIS_INSTR" != "X"	# {
      then
	case $SOLARIS_INSTR in	# {
	amd64*)
	  LSOF_TMP2="/amd64"
	  ;;
	sparcv9*)
	  LSOF_TMP2="/sparcv9"
	  ;;
	esac	# }
      fi	# }

    # See if the correct library has been specified and exists.

      if test "X$SOLARIS_VXFSLIB" = "X"	# {
      then
	SOLARIS_VXFSLIB=`dirname $SOLARIS_VXFSINCL`/lib
      fi	# }
      LSOF_TMP3="${SOLARIS_VXFSLIB}${LSOF_TMP2}/libvxfsutil.a"
      if test ! -r $LSOF_TMP3	# {
      then
	echo "!!!FATAL: no VxFS $LSOF_TMP3"
	exit 1
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -L$SOLARIS_VXFSLIB${LSOF_TMP2} -lvxfsutil -ldl"

    # See if the library has the Reverse Name Lookup (RNL) function.

      nm $LSOF_TMP3 | grep vxfs_inotopath > /dev/null 2>&1
      if test $? -eq 0	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVXFSRNL -DHASVXFSDNLC"
      fi	# }
    else

    # See if there are VxFS header files for VxFS versions below 3.4.

      if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h	# {
      then

      # Define VxFS for VxFS versions below 3.4.  Make additional header
      # file tests.

	LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_fs.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_FS_H"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_sol.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOL_H"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_machdep.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_MACHDEP_H"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/fs/vx_solaris.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_SOLARIS_H"
	  grep "off32_t;" ${LSOF_INCLUDE}/sys/fs/vx_machdep.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF32_T"
	  fi	# }
	  grep "off64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASVXFS_OFF64_T"
	  fi	# }
	  grep "vx_u64_t;" ${LSOF_INCLUDE}/sys/fs/vx_solaris.h > /dev/null
	  if test $? -eq 0	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHASVXFS_U64_T"
	  fi	# }
	fi	# }
	egrep "struct[ 	]vx_inode[ 	]\{" ${LSOF_INCLUDE}/sys/fs/vx_inode.h > /dev/null
	# } (dummy '}' to match '{' in above egrep)
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASVXFS_VX_INODE"
	fi	# }
      fi	# }
    fi	# }

    # Set libraries and dialect subdirectory.

    LSOF_CFGL="$LSOF_CFGL -lkvm -lelf -lsocket -lnsl"
    LSOF_DIALECT_DIR=sun

    # Set local-specific stuff.

    if test "X$LSOF_LOCALSUFFIX" = "XLOCAL"	# {
    then
      LSOF_DOC="\${DESTDIR}/usr/local/man"
    fi	# }
    ;;

# Configure for SCO|Caldera OpenServer Release 6.0.0 and UnixWare.

  osr6|unixware|uw)
    LSOF_TMP1=$LSOF_TGT
    LSOF_TGT="uw"
    if test "X$LSOF_RANLIB_SUP" = "X"	# {
    then
      LSOF_RANLIB=""
    fi	# }
    if test "X$LSOF_VSTR" = "X"	# {
    then
      LSOF_VSTR=`uname -v`
    fi	# }
    if test "X$LSOF_VERS" = "X"	# {
    then

      # If the Openserver Release 6.0.0 or UnixWare version isn't pre-defined,
      # determine it.

      LSOF_VERS=`echo $LSOF_VSTR | sed 's/\([0-9\.]*\).*/\1/; s/\./ /g' | awk '{printf "%d%02d%02d\n", $1, $2, $3;}'`
    fi	# }
    if test $LSOF_TMP1 = "osr6"	# {
    then
      LSOF_CINFO="OSR6 support via UnixWare sources"

    # Convert the OpenServer Release 6.0.0 version number to a UnixWare one.

      case $LSOF_VERS in	# {
      60000)
	LSOF_VERS=70104
	;;
      *)
	echo "Unknown OpenServer Release version: $LSOF_VERS"
	rm -f $LSOF_HLP
	exit 1
      esac	# }
    fi	# }
    LSOF_CFGF="$LSOF_CFGF -DUNIXWAREV=$LSOF_VERS"

    # Do OpenServer Release 6.0.0 and UnixWare version-specific stuff.

    case $LSOF_VERS in	# {
    20100|20101|20102|20103)
      if test -r ${LSOF_INCLUDE}/sys/fs/vx_inode.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lsocket -lnsl -lelf -lgen"
      ;;
    70000|70001|70100|70101|70103|70104)
      LSOF_TSTBIGF=" "
      LSOF_TSTLFLG="-lsocket -lnsl"
      if test $LSOF_VERS -lt 70103	# {
      then
	LSOF_DINC="$LSOF_DINC -I`pwd`/dialects/uw/uw7"
      else	# $LSOF_VERS -ge 70103

      # Process 7.1.3 and above.

	if test -r ${LSOF_INCLUDE}/netinet/in6.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHASIPv6"
	fi	# }
	if test $LSOF_VERS -ge 70104	# {
	then

	# Process 7.1.4 and above.

	  LSOF_TMP1=0
	  if test -r ${LSOF_INCLUDE}/netinet/in_pcb.h	# {
	  then
	    grep INKERNEL ${LSOF_INCLUDE}/netinet/in_pcb.h > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      LSOF_TMP1=1
	    fi	# }
	  fi	# }
	  if test $LSOF_TMP1 -eq 0 -a -r ${LSOF_INCLUDE}/netinet/tcp_var.h   # {
	  then
	    grep INKERNEL ${LSOF_INCLUDE}/netinet/tcp_var.h > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      LSOF_TMP1=1
	    fi	# }
	  fi	# }
	  if test $LSOF_TMP1 -eq 1	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DHAS_INKERNEL"
	  fi	# }
	fi	# }
      fi	# }
      if test ! -r ${LSOF_INCLUDE}/vm/swap.h -a -r ${LSOF_INCLUDE}/sys/swap.h	# {
      then
	(cd ./dialects/uw/uw7/vm; rm -f swap.h; ln -s ${LSOF_INCLUDE}/sys/swap.h swap.h)
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/fs/vx_gemini.h	# {
      then
	LSOF_CFGF="$LSOF_CFGF -DHASVXFS"
      fi	# }
      LSOF_CFGL="$LSOF_CFGL -lsocket -lnsl -lelf -lgen"
      /bin/pkginfo 2> /dev/null | grep -i patch | grep -i ptf7038 > /dev/null
      if test -r ${LSOF_INCLUDE}/sys/file.h	# {
      then
	grep f_open ${LSOF_INCLUDE}/sys/file.h > /dev/null
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_F_OPEN"
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/fs/cdfs_fs.h	# {
      then
	grep "cdfs_LogSecShift;" ${LSOF_INCLUDE}/sys/fs/cdfs_fs.h > /dev/null 2>&1
	if test $? -eq 0	# {
	then
	  LSOF_TMP=`grep "cdfs_LogSecShift;" ${LSOF_INCLUDE}/sys/fs/cdfs_fs.h | sed 's/^[ 	]*\([^ 	]*\).*/\1/'`
	  if test "X$LSOF_TMP" != "X"	# {
	  then
	    LSOF_CFGF="$LSOF_CFGF -DTYPELOGSECSHIFT=$LSOF_TMP"
	  fi	# }
	fi	# }
      fi	# }
      if test -r ${LSOF_INCLUDE}/sys/proc.h	# {
      then
	grep p_pgid ${LSOF_INCLUDE}/sys/proc.h > /dev/null
	if test $? -eq 0	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_P_PGID"
	fi	# }
      fi	# }
      if test $LSOF_VERS -ge 70101	# {
      then

	# Do OpenServer Release 6.0.0 and UnixWare 7.1.1 and above tests, as
	# required.

	if test "X$UW_HAS_NSC" = "X"	# {
	then
	  UW_HAS_NSC=N
	  if test -x /bin/node_self	# {
	  then
	    /bin/node_self > /dev/null 2>&1
	    if test $? -eq 0	# {
	    then
	      UW_HAS_NSC=Y
	    fi	# }
	  fi	# }
	fi	# }
	if test "X$UW_HAS_NSC" = "XY" -o "X$UW_HAS_NSC" = "Xy" 	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_UW_NSC"
	  LSOF_CFGL="$LSOF_CFGL -lcluster"
	fi	# }
	if test -r ${LSOF_INCLUDE}/sys/nsc_synch.h	# {
	then
	  LSOF_CFGF="$LSOF_CFGF -DHAS_UW_CFS"
	fi	# }
      fi	# }
      ;;
    *)
      echo Unsupported UnixWare version: `uname -v`
      rm -f $LSOF_HLP
      exit 1
      ;;
    esac	# }
    if test -r ${LSOF_INCLUDE}/sys/fs/xnamnode.h	# {
    then
      LSOF_CFGF="$LSOF_CFGF -DHASXNAMNODE"
    fi	# }
    LSOF_DIALECT_DIR=uw
    ;;

# Handle unknown abbreviation.

  *) 
    echo "Can't configure for $LSOF_TGT."
    cat $LSOF_HLP
    rm -f $LSOF_HLP
    exit 1
    ;;

# End of LSOF_TGT cases

esac	# }

# Do an inventory of the distribution, as required.

if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverInv	# {
then
  if test ! -f ./Inventory	# Want -x, but Ultrix doesn't grok it.	# {
  then
    echo "Can't find Inventory script."
    rm -f $LSOF_HLP
    exit 1
  fi	# }
  ./Inventory
fi	# }

# Make sure target directory exists.

if test ! -d ./dialects/$LSOF_DIALECT_DIR	# {
then
  echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR doesn't exist."
  rm -f $LSOF_HLP
  exit 1
fi	# }

# Make sure $LSOF_MK exists in the target directory.

if test ! -r ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK	# {
then
  echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK doesn't exist."
  rm -f $LSOF_HLP
  exit 1
fi	# }

# Make sure $LSOF_MKF, $LSOF_SPMKF, or $LSOF_MKF.$LSOF_LOCALSUFFIX) exists
# in the target directory.

if test "X$LSOF_SPMKF" != "X"	# {
then
  LSOF_TMP1=$LSOF_SPMKF
else
  LSOF_TMP1=$LSOF_MKF
fi	# }
if test "X$LSOF_LOCALSUFFIX" != "X"	# {
then
  LSOF_REST=$LSOF_TMP1.$LSOF_LOCALSUFFIX
else
  LSOF_REST=$LSOF_TMP1
fi	# }
if test ! -r ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST	# {
then
  echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST doesn't exist."
  rm -f $LSOF_HLP
  exit 1
fi	# }

# If this is FreeBSD, make sure $LSOF_FBSD_ZFS_MKF exists.

if test $LSOF_FBSD_ZFS -eq 1	# {
then
  if test ! ./dialects/$LSOF_DIALECT_DIR/$LSOF_FBSD_ZFS_MKF	# {
  then
    echo "Can't configure for $LSOF_TGT -- ./dialects/$LSOF_DIALECT_DIR/$LSOF_FBSD_ZFS_MKF doesn't exist."
    rm -f $LSOF_HLP
    exit 1
  fi	# }
fi	# }}

# Make sure $LSOF_VF exists.  Extract the version number from it.

if test ! -r $LSOF_VF	# {
then
  echo "Version number file, ./$LSOF_VF, doesn't exist."
  rm -f $LSOF_HLP
  exit 1
else
  LSOF_VN=`sed "s/.ds VN \(.*\)/\1/" < $LSOF_VF`
fi	# }

# Clean up in advance.

rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF $LSOF_TSTCFLG $LSOF_TSTCC
rm -f $LSOF_TSTXOC $LSOF_TSTLFF
echo "rm -f $LSOF_F $LSOF_MKFC $LSOF_FBSD_ZFS_MKF $LSOF_TSTCFLG"
echo "rm -f $LSOF_TSTCC $LSOF_TSTXOC $LSOF_TSTLFF"

# Make sure there's a C compiler name.

if test "X$LSOF_CC" = "X"	# {
then
  LSOF_CC=cc
fi	# }

# Do common feature analyses.

# Check for localtime(3) and strftime(3).

rm -f ${LSOF_TMPC}.*
cat > $LSOF_TMPC.c << .LSOF_END_HERE_DOC2
#include <time.h>
main(){
  time_t cl;
  struct tm *ts;
  char bf[32];
  if ((cl = time(NULL)) == (time_t)-1)
    return(1);
  ts = localtime(&cl);
  if (strftime(bf, sizeof(bf), "%D", ts) != 8)
    return(1);
  if ((bf[2] != '/') || (bf[5] != '/'))
    return (1);
  return(0);
}
.LSOF_END_HERE_DOC2
echo $EO "Testing C library for localtime() and strftime(), using $LSOF_CC ... $EC"
$LSOF_CC ${LSOF_TMPC}.c -o ${LSOF_TMPC}.x > /dev/null 2>&1
if test -x ${LSOF_TMPC}.x	# {
then
  ./${LSOF_TMPC}.x
  if test $? -eq 0	# }
  then
    LSOF_CFGF="$LSOF_CFGF -DHAS_STRFTIME"
    echo "present"
  else
    echo "unusable"
  fi	# }
else
  echo "missing"
fi	# }
rm -f ${LSOF_TMPC}.[cox]

# Make the dialect sources.

if test "X$LSOF_MKC" = "X"	# {
then
  LSOF_MKC="ln -s"
fi	# }
LSOF_MKC=$LSOF_MKC ./dialects/$LSOF_DIALECT_DIR/$LSOF_MK $LSOF_TGT $LSOF_VERS

# Make $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF.

echo "# $LSOF_TGT Makefile for lsof revision $LSOF_VN" > $LSOF_MKFC
echo "" >> $LSOF_MKFC
echo "CC=	$LSOF_CC" >> $LSOF_MKFC
if test "X$LSOF_CCV" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "CCV=	$LSOF_CCV" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_LIB_NO" = "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "LIB=	${LSOF_LIB}/liblsof.a" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_LD" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "LD=	$LSOF_LD" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_CINFO" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "CINFO=	$LSOF_CINFO" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_CFGD" != "X"	# {
then
  echo "CFGD=	$LSOF_CFGD" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_CFGDN" != "X"	# {
then
  echo "CFGDN=	$LSOF_CFGDN" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_ARCH" != "X"	# {
then
  LSOF_CFGF="$LSOF_CFGF -DLSOF_ARCH=\\\"$LSOF_ARCH\\\""
fi	# }
if test "X$LSOF_VSTR" != "X"	# {
then
  LSOF_TMP=`echo $LSOF_VSTR | sed 's/(/\\\\(/g' | sed 's/)/\\\\)/g'`
  LSOF_CFGF="$LSOF_CFGF -DLSOF_VSTR=\\\"$LSOF_TMP\\\""
fi	# }
echo "" >> $LSOF_MKFC
echo "CFGF=	$LSOF_CFGF" >> $LSOF_MKFC
if test "X$LSOF_LIB_NO" = "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "CFGL=	$LSOF_FCFGL -L./$LSOF_LIB -llsof $LSOF_CFGL" >> $LSOF_MKFC
fi	# }
echo "" >> $LSOF_MKFC
if test "X$LSOF_DEBUG" = "X"	# {
then
  LSOF_DEBUG="-O"
else
  if test "X$LSOF_DEBUG" = "XNo-O"	# {
  then
    LSOF_DEBUG=""
  fi	# }
fi	# }
echo "DEBUG=	$LSOF_DEBUG" >> $LSOF_MKFC
if test "X$LSOF_DINC" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "DINC=	$LSOF_DINC" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_DOC" != "X"	# {
then
  echo "" >> $LSOF_MKFC
  echo "DOC=$LSOF_DOC" >> $LSOF_MKFC
fi	# }
if test "X$LSOF_DISTRIBKVM" != "X" -a "X$LSOF_DISTRIBKVM" != "XKVM"	# {
then
  echo "" >> $LSOF_MKFC
  echo "KVM=	$LSOF_DISTRIBKVM" >> $LSOF_MKFC
fi	# }
rm -f ${LSOF_LIB}/$LSOF_LIBMKF
if test "X$LSOF_LIB_NO" = "X"	# {
then
  cp $LSOF_MKFC ${LSOF_LIB}/$LSOF_LIBMKF
fi	# }
cat ./dialects/$LSOF_DIALECT_DIR/$LSOF_REST >> $LSOF_MKFC
if test "X$LSOF_LIB_NO" = "X"	# {
then

  # Put archiving and optional randomizing strings in ${LSOF_LIB}/$LSOF_LIBMKF.
  #
  # Process optional CFLAGS override.
  #
  # Add the library Makefile skeleton section.

  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  if test "X$LSOF_AR" = "X"	# {
  then
    echo "AR=	ar cr \${LIB} \${OBJ}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  else
    echo "AR=	$LSOF_AR \${LIB} \${OBJ}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  fi	# }
  if test "X$LSOF_RANLIB" != "X"	# {
  then
    echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
    echo "RANLIB=	$LSOF_RANLIB \${LIB}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  fi	# }
  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  if test "X$LSOF_CFLAGS_OVERRIDE" = "X"	# {
  then
    echo "CFLAGS=	\${CDEFS} \${INCL} \${DEBUG}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  else
    echo "override CFLAGS=\${CDEFS} \${INCL} \${DEBUG}" >> ${LSOF_LIB}/$LSOF_LIBMKF
  fi	# }
  echo "" >> ${LSOF_LIB}/$LSOF_LIBMKF
  cat ${LSOF_LIB}/$LSOF_LIBMKFSKEL >> ${LSOF_LIB}/$LSOF_LIBMKF
  echo $LSOF_MKFC and ${LSOF_LIB}/$LSOF_LIBMKF created.
else
  echo $LSOF_MKFC created.
fi	# }

# If this is FreeBSD, create $LSOF_FBSD_ZFS_MKF.

if test $LSOF_FBSD_ZFS -eq 1	# {
then
  rm -f $LSOF_FBSD_ZFS_MKF
  echo "# $LSOF_TGT ZFS Makefile for lsof revision $LSOF_VN" > $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  echo "CC=		$LSOF_CC" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  echo "CFLAGS=	$LSOF_FBSD_ZFS_CFGF" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  if test "X$LSOF_DEBUG" = "X"	# {
  then
    LSOF_DEBUG="-O"
  else
    if test "X$LSOF_DEBUG" = "XNo-O"	# {
    then
      LSOF_DEBUG=""
    fi	# }
  fi	# }
  echo "DEBUG=	$LSOF_DEBUG" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  echo "OPENSOLARIS=	$LSOF_FBSD_ZFS_SYS" >> $LSOF_FBSD_ZFS_MKF
  echo "" >> $LSOF_FBSD_ZFS_MKF
  cat ./dialects/$LSOF_DIALECT_DIR/$LSOF_FBSD_ZFS_MKF >> $LSOF_FBSD_ZFS_MKF
  echo $LSOF_FBSD_ZFS_MKF created.
fi	# }

# Create test cc file.

echo "$LSOF_CC" > $LSOF_TSTCC
echo "$LSOF_TSTCC created"

# Create test cflags file.

echo "-DLT_DIAL_$LSOF_TGT" > $LSOF_TSTCFLG
if test "X$LSOF_TSTBIGF" != "X"	# {
then
  echo "-DLT_BIGF" >> $LSOF_TSTCFLG
  if test "X$LSOF_TSTBIGF" != "X "	# {
  then
    for i in $LSOF_TSTBIGF	# {
    do
      echo "$i" >> $LSOF_TSTCFLG
    done	# }
  fi	# }
fi	# }
if test "X$LSOF_TSTDFLG" != "X"	# {
then
  for i in $LSOF_TSTDFLG	# {
  do
    echo "$i" >> $LSOF_TSTCFLG
  done	# }
fi	# }
echo $LSOF_CC | grep gcc > /dev/null 2>&1
if test $? -eq 0	# {
then
  echo "-DLT_GCC" >> $LSOF_TSTCFLG
else
  echo "-DLT_CC" >> $LSOF_TSTCFLG
fi	# r}
if test $LSOF_TSTKMEM -eq 1	# {
then
  echo "-DLT_KMEM" >> $LSOF_TSTCFLG
fi	# }
if test $LSOF_TSTK64 -eq 1	# {
then
  echo "-DLT_K64" >> $LSOF_TSTCFLG
fi	# }
echo "-DLT_VERS=$LSOF_VERS" >> $LSOF_TSTCFLG
if test $LSOF_TSTVPATH -eq 1	# {
then
  echo "-DLT_VPATH" >> $LSOF_TSTCFLG
fi	# }
echo "$LSOF_TSTCFLG created"

# Create tests loader flags file.

echo $LSOF_TSTLFLG > $LSOF_TSTLFF
echo "$LSOF_TSTLFF created"

# Create test extra objects file.

echo "$LSOF_TSTXO" > $LSOF_TSTXOC
echo "$LSOF_TSTXOC created"

rm -f $LSOF_HLP

# Call Customize, as required.

if test "X$LSOF_SCRIPT_CALL" = "Xyes" -a ! -r ./.neverCust	# {
then
  if test ! -f ./Customize	# {  Want -x, but Ultrix doesn't grok it.
  then
    echo "Can't find Customize script."
    exit 1
  fi	# }
  ./Customize $LSOF_DIALECT_DIR
fi	# }

# Issue unsupported warning, as appropriate.

if test "X$LSOF_UNSUP" != "X"	# {
then
  echo "$LSOF_UNSUP"
fi	#}
exit 0
